Garry's Mod Wiki

cam.Start2D

  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. To set its position use render.SetViewPort with a target already stored.

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.
This is a rendering hook which provides a 2d rendering context.

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 )