surface.DrawTexturedRect

November 2016
4 Posts
Hey guys I’m fairly new to gmod developing and developing in general and I’m trying to add an element to the HUD with a custom texture. The problem is I don’t know where the vtf/png file should go and how to set the texture as the texture of the surface rectangle. Everytime I attempt to use the texture I get the purple and black checkers.



local mat = Material("testTexture.vtf")

hook.Add("HUDPaint","testHUD",function()
	surface.SetDrawColor(255,255,255,255)
	surface.SetMaterial(mat)
	surface.DrawTexturedRect(0,0,512,512)
end)


I have the vtf file stored inside my materials folder. The materials folder is inside the lua folder of my addon. Thanks for the help!

I understand it is a dumb question, but I would greatly appreciate some assistance!

It could have something to do with the file itself. I haven’t touched .vtf extensions in awhile, but does it have an accompanying .vmt?

.vtf files also can only be the size to a power of two.

I don’t think you need to specify the file extension, just the path (without extension) from the materials/ folder to the vmt file (excluding the .vmt part)