Skip to content

Instantly share code, notes, and snippets.

View Codingale's full-sized avatar

Codingale Codingale

  • 07:45 (UTC -04:00)
View GitHub Profile
@Codingale
Codingale / cl_surfaceGetURL.lua
Last active October 15, 2019 15:47 — forked from mattkrins/cl_surfaceGetURL.lua
This is a simple Garry's Mod helper function to hot-load images from a web URL for use in your rendering operations.
local WebMaterials = {}
function surface.GetURL(url, w, h, time)
if not url or not w or not h then return Material("error") end
if WebMaterials[url] then return WebMaterials[url] end
local WebPanel = vgui.Create( "HTML" )
WebPanel:SetAlpha( 0 )
WebPanel:SetSize( tonumber(w), tonumber(h) )
WebPanel:OpenURL( url )
WebPanel.Paint = function(self)
if not WebMaterials[url] and self:GetHTMLMaterial() then