Simple clientside code to render a logo.png at top left of screen?
10 replies, posted
Been playing around these 2 wiki pages trying to figure something out but no luck
GM:HUDPaint
surface.SetMaterial
Just need a simple code to put in lua/autorun/client that will render a logo at top left of screen.
You're on the right tracks but don't set material inside hudpaint or your fps is dead
Just use surface.DrawTexturedRect and you should be good to go
No it won't? Maybe you're thinking about creating fonts? You have to use surface.SetMaterial for surface.DrawTexturedRect to work properly
local logo = Material('you/logo.png')
hook.Add('HUDPaint', 'whatever', function()
surface.SetDrawColor(255,255,255,255)
surface.SetMaterial(logo)
surface.DrawTexturedRect(5,5,100,50)
end)
Just noticed where i went wrong
I meant it exactly how you have done, make a local variable outside of the hudpaint or you will experience frame drop
That's a myth. You won't experience a significant frame drop since it only loads the material once.
From the wiki: "Either returns the material with the given name, or loads the material interpreting the first argument as the path."
It's more efficient to put it outside the function yeah but it's a really insignificant difference.
Oh, i see. Well my bad
I just stick to these kind of "rules"
local logo = Material('you/logo.png')
hook.Add('HUDPaint', 'whatever', function()
surface.SetDrawColor(255,255,255,255)
surface.SetMaterial(logo)
surface.DrawTexturedRect(5,5,100,50)
end)
Doesn't seem to work, No matter where I put the logo it doesn't seem to call upon that directory, always purple and black boxes. And yes I've added the logo.png to fastdl
You might want to change
local logo = Material('you/logo.png')
to your material.
That was just the example I pasted that the guy posted above.
I have tried things like
and still purple and black, even with it on the fastdl.
local logo = Material('materials/logo/logo.png')
Don't prefix the path with "materials/"
Have you tried
resource.AddSingleFile("path")
Sorry, you need to Log In to post a reply to this thread.