GraphicsDevice.SetRenderTarget Method (RenderTarget2D)

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 abstract void SetRenderTarget(
	RenderTarget2D renderTarget
)

Parameters

renderTarget
Type: Microsoft.Xna.Framework.Graphics.RenderTarget2D
A new render target for the device, or null to set the device render target to the back buffer of the device.

ExceptionCondition
ArgumentException

An invalid render target index was requested.

ArgumentOutOfRangeException

The 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.

Silverlight

Supported in: 5

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: