Garry's Mod Wiki

render.SetViewPort

  render.SetViewPort( number x, number y, number w, number h )

Description

Changes the view port position and size. The values will be clamped to the game's screen resolution.

If you are looking to render something to a texture (render target), you should use render.PushRenderTarget.

This function will override values of ScrW and ScrH with the ones you set.

Arguments

1 number x
X origin of the view port.
2 number y
Y origin of the view port.
3 number w
Width of the view port.
4 number h
Height of the view port.

Example

Renders a screen with a dimension of 32 X 32 and resets the render system to normal.

local oldW, oldH = ScrW(), ScrH() local oldRT = render.GetRenderTarget() render.SetRenderTarget(RTName) render.Clear(0,0,0,255) render.SetViewPort(0,0,32,32) render.RenderView(CamData) render.SetRenderTarget(oldRT) render.SetViewPort(0,0,oldW,oldH)