• surface.DrawTexturedRect() not drawing
    2 replies, posted
I am making a persistent tool and im making a custom screen for it that displays a icon, but this icon wont show up. I did find a way to fix it but that requires that I break rendering once, and that gives errors. Code for screen: [code]local materialTick = Material("icon16/tick.png") local materialCross = Material("icon16/cross.png") function TOOL:DrawToolScreen(width, height) local trace = LocalPlayer():GetEyeTrace() cam.Start2D() surface.SetDrawColor(255, 255, 255, 255) surface.DrawRect(0, 0, width, height) --White background draw.RoundedBox(16, 5, 5, width-10, height-10, Color(100, 149, 237, 255)) --Cornflower blue rounded box draw.DrawText("#Tool.entity_saver.name", "EntityLoaderScreenFont", width/2, 12, Color(255, 255, 255, 255), 1) --Tool name text surface.SetDrawColor(255, 255, 255, alpha) surface.DrawRect(5, 60, width-10, 2) --Line under text --Drawing indicator icon if self:CanShoot(trace) then --Only draw icon if looking at entity surface.SetDrawColor(255, 255, 255, 255) surface.SetMaterial(trace.Entity:GetPersistent() and materialTick or materialCross) surface.DrawTexturedRect((width/2)-(150/2), (height/2)-(150/2)+25, 150, 150) end cam.End2D() end[/code] So what am I doing wrong?
My friend and I are getting this as well, in exactly the same spot. The material shows up in mat_texture_list and non-textured objects render, but materials either don't work at all (in my case) or work sporadically (in my friend's case). EDIT: The material you are using needs these attributes in the vmt: [code] "UnlitGeneric" { "$basetexture" "path/to/your/vtf/without/extension" "$ignorez" 1 "$vertexcolor" 1 "$vertexalpha" 1 "$nolod" 1 } [/code]
You didn't specify a shader to use. Material("icon16/tick.png", "unlitgeneric") [url]http://gmodwiki.net/Lua/Global/Material[/url] [editline]a[/editline] Oh wow this is old.
Sorry, you need to Log In to post a reply to this thread.