Partager via


GraphicsDevice.SetRenderTarget Method (RenderTarget2D)

Sets a new render target for this GraphicsDevice.

Syntax

'Declaration
Public Sub SetRenderTarget ( _
         renderTarget As RenderTarget2D _
)
public void SetRenderTarget (
         RenderTarget2D renderTarget
)
public:
void SetRenderTarget(
         RenderTarget2D renderTarget
)

Parameters

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

Exceptions

Exception type Condition
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.

Remarks

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.

Requirements

Namespace: Microsoft.Xna.Framework.Graphics

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

See Also

Reference

GraphicsDevice Class
GraphicsDevice Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Windows Phone