Panel.GetHTMLMaterial

From GMod Wiki

Jump to: navigation, search
Function
Syntax P.HTML:GetHTMLMaterial( )
Description:
Returns a IMaterial object that can be used with render.SetMaterial()
Returns: nil
In Object: HTML
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Panel.GetHTMLMaterial]Panel.GetHTMLMaterial [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]




Usage

DescriptionCreates A HTML Screen Drawn on the World
Used onNewerClient.png
Code
 
local pos = Vector(0, 0, 0)
local ang = Angle(0, 270, 90)
local width = 1024
local height = 768
local scale = 0.125
local url = "http://google.com"
 
if g_3DHTML and g_3DHTML:IsValid() then g_3DHTML:Remove() end
local browser = vgui.Create("HTML")
      g_3DHTML = browser
      browser:SetPaintedManually(true)
      browser:SetSize(width, height)
      browser:SetMouseInputEnabled(false)
      browser:OpenURL(url)
 
local function DrawSign()
        -- Draw a background
        surface.SetDrawColor(255, 255, 255, 255)
        surface.DrawRect(0, 0, width, height)
 
        -- Draw the screen
        render.SetMaterial(browser:GetHTMLMaterial())
        render.DrawQuad(Vector(0, 0, 0),
                Vector(width, 0, 0),
                Vector(width, height, 0),
                Vector(0, height, 0))
end
 
hook.Add("RenderScreenspaceEffects", "3DHTMLSign", function()
     cam.Start3D(EyePos(), EyeAngles())
     cam.Start3D2D(pos, ang, scale)
     local status, err = pcall(DrawSign)
     cam.End3D2D()
     if not status then Error(err) end
end)
 
OutputNone
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox