render/SetViewPort

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Actually use bug tag)
 
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=SetViewPort
+
|Description=Changes the view port position and size. The values will be clamped to the game's screen resolution.
|Parent=render
+
 
|Description=Changes the view port position and size.
+
If you are looking to render something to a texture (render target), you should use {{LibraryFunction|render|PushRenderTarget}}.
  
 
{{Note|This function will override values of {{GlobalFunction|ScrW}} and {{GlobalFunction|ScrH}} with the ones you set.}}
 
{{Note|This function will override values of {{GlobalFunction|ScrW}} and {{GlobalFunction|ScrH}} with the ones you set.}}
  
{{Bug|Issue=1424|Arguments are clamped to the client's screen bounds, disallowing render targets bigger than the screen. {{LibraryFunction|render|PushRenderTarget}} doesn't suffer from this.}}
 
 
|Realm=Client
 
|Realm=Client
 
|IsClass=No
 
|IsClass=No
Line 39: Line 38:
 
render.SetViewPort(0,0,32,32)
 
render.SetViewPort(0,0,32,32)
 
render.RenderView(CamData)
 
render.RenderView(CamData)
render.SetRenderTarget(oldRT)
+
render.SetRenderTarget(oldRT)
 
render.SetViewPort(0,0,oldW,oldH)
 
render.SetViewPort(0,0,oldW,oldH)
 
}}
 
}}

Latest revision as of 16:25, 16 October 2019

 render.SetViewPort( )

Contents

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.

NOTE

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

Arguments

number x

X origin of the view port.

Arguments

number y

Y origin of the view port.

Arguments

number w

Width of the view port.

Arguments

number h

Height of the view port.

Examples

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)


Personal tools
Navigation