GraphicsDevice.SetRenderTarget Method (RenderTarget2D)

XNA Game Studio 4.0
Sets a new render target for this GraphicsDevice.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in microsoft.xna.framework.graphics.dll)

public void SetRenderTarget (
         RenderTarget2D renderTarget
)

Parameters

renderTarget
A new render target for the device, or null to set the device render target to the back buffer of the device.

Exception typeCondition
ArgumentException An invalid render target index was requested. On Xbox 360, there is only one render target available and renderTargetIndex must be zero.
ArgumentOutOfRangeExceptionThe render target index must be within the valid range for this device.
ObjectDisposedException SetRenderTarget was called after this renderTarget was disposed.

The following restrictions apply when using this method.

  • The multisample type must be the same for the render target and the depth stencil surface.
  • The formats must be compatible for the render target and the depth stencil surface.
  • The size of the depth stencil surface must be greater than or equal to the size of the render target.

These restrictions are validated only when using the debug runtime when any of the GraphicsDevice drawing methods are called.

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone 7

Community Additions

ADD
Show: