surface.DrawTexturedRect

From Garry's Mod
Revision as of 14:25, 24 May 2017 by JasonMan (Talk | contribs)
Jump to: navigation, search
 surface.DrawTexturedRect( )

Contents

Description

Draw a textured rectangle with the given position and dimensions on the screen, using the current active texture set with surface.SetMaterial

See also render.SetMaterial and render.DrawScreenQuadEx.

NOTE

This is a rendering function that requires a 2D rendering context.
This means that it will only work in hooks with a 2D rendering context.

Arguments

number x

The X co-ordinate.

Arguments

number y

The Y co-ordinate.

Arguments

number width

The width of the rectangle.

Arguments

number height

The height of the rectangle.

Examples

Example

Draws a 512x512 textured rectangle with the wireframe texture.

local ourMat = Material( "models/wireframe" ) -- Calling Material() every frame is quite expensive

hook.Add( "HUDPaint", "example_hook", function()
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( ourMat  ) -- If you use Material, cache it!
	surface.DrawTexturedRect( 0, 0, 512, 512 )
end )


Personal tools
Navigation