Garry's Mod Wiki


surface.DrawTexturedRect( number x, number y, number width, number height )


Draw a textured rectangle with the given position and dimensions on the screen, using the current active texture set with surface.SetMaterial. It is also affected by surface.SetDrawColor.

See also render.SetMaterial and render.DrawScreenQuadEx.
See also surface.DrawTexturedRectUV.

This is a rendering function that requires a 2d rendering context.

This means that it will only work in 2d Rendering Hooks.


1 number x
The X integer co-ordinate.
2 number y
The Y integer co-ordinate.
3 number width
The integer width of the rectangle.
4 number height
The integer height of the rectangle.


Draws a 512x512 textured rectangle with the wireframe texture.

-- Calling Material() every frame is quite expensive -- So we call it once, outside of any hooks, and cache the result in a local variable local ourMat = Material( "models/wireframe" ) hook.Add( "HUDPaint", "PutAUniqueHookNameHere", function() surface.SetDrawColor( 255, 255, 255, 255 ) -- Set the drawing color surface.SetMaterial( ourMat ) -- Use our cached material surface.DrawTexturedRect( 0, 0, 512, 512 ) -- Actually draw the rectangle end )

Page Links

Special Pages



Render Time: 85ms

DB GetPage 47
Generate Html 15
SaveChanges (1) 13
Render Body 0
Render Sidebar 8