render/PushRenderTarget

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=PushRenderTarget
 
|Parent=render
 
 
|Description=Pushes the current render target and viewport to the RT stack then sets a new current render target and viewport. If the viewport is not specified, the dimensions of the render target are used instead.
 
|Description=Pushes the current render target and viewport to the RT stack then sets a new current render target and viewport. If the viewport is not specified, the dimensions of the render target are used instead.
  
Line 10: Line 8:
 
{{Note|If you want to render to the render target in 2d mode and it is not the same size as the screen, use {{LibraryFunction|cam|Start2D}} and {{LibraryFunction|cam|End2D}}.}}
 
{{Note|If you want to render to the render target in 2d mode and it is not the same size as the screen, use {{LibraryFunction|cam|Start2D}} and {{LibraryFunction|cam|End2D}}.}}
 
{{Note|If the render target is bigger than the screen, rendering done with the surface library will be clipped to the screen bounds unless you call {{LibraryFunction|surface|DisableClipping}} }}
 
{{Note|If the render target is bigger than the screen, rendering done with the surface library will be clipped to the screen bounds unless you call {{LibraryFunction|surface|DisableClipping}} }}
 +
{{Bug|Issue=1424|In certain cases(?), manual offsets will be needed on the X and Y origins of the viewport to compensate for the first several pixels being cut off.}}
 
|Realm=Client
 
|Realm=Client
 
|IsClass=No
 
|IsClass=No

Revision as of 23:36, 10 October 2019

 render.PushRenderTarget( )

Contents

Description

Pushes the current render target and viewport to the RT stack then sets a new current render target and viewport. If the viewport is not specified, the dimensions of the render target are used instead.

This is similar to a call to render.SetRenderTarget and render.SetViewPort where the current render target and viewport have been saved beforehand, except the viewport isn't clipped to screen bounds.

See also render.PopRenderTarget.

NOTE

If you want to render to the render target in 2d mode and it is not the same size as the screen, use cam.Start2D and cam.End2D.

NOTE

If the render target is bigger than the screen, rendering done with the surface library will be clipped to the screen bounds unless you call surface.DisableClipping

BUG

In certain cases(?), manual offsets will be needed on the X and Y origins of the viewport to compensate for the first several pixels being cut off.

Issue Tracker: #1424

Arguments

ITexture texture

The new render target to be used.

Arguments

number x=0

X origin of the viewport.

Arguments

number y=0

Y origin of the viewport.

Arguments

number w=texture:Width()

Width of the viewport.

Arguments

number h=texture:Height()

Height of the viewport

Examples

Example

Shows how you can use alpha channel with render targets.

render.PushRenderTarget( texture )
render.OverrideAlphaWriteEnable( true, true )

render.ClearDepth()
render.Clear( 0, 0, 0, 0 )

render.OverrideAlphaWriteEnable( false )
render.PopRenderTarget()


Personal tools
Navigation