cam.Start2D

From Garry's Mod
Jump to: navigation, search
 cam.Start2D( )

Description

Sets up a new 2D rendering context. Must be finished by cam.End2D.

This is almost always used with a render target from the render library. To set its position use render.SetViewPort with a target already stored.

NOTE

This will put an identity matrix at the top of the model matrix stack. If you are trying to use cam.PushModelMatrix, call it after this function and not before.

NOTE

This is a function that starts a 2D rendering context.
This means that the only rendering functions will work after it are functions with a 2D rendering context.

Examples

Example

Sets the viewport then draws on the view with 2d methods

local oldW, oldH = ScrW(), ScrH()
render.SetViewPort( 0, 100, 50, 50 )
cam.Start2D()
	surface.SetDrawColor( 255, 255, 255 )
	surface.DrawLine( 10, 10, 100, 100 )
cam.End2D()
render.SetViewPort( 0, 0, oldW, oldH )


Personal tools
Navigation