Compartir a través de


GraphicsDevice.SetRenderTarget Method (RenderTarget2D)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Sets a new render target for this GraphicsDevice.

Namespace:  Microsoft.Xna.Framework.Graphics
Assembly:  Microsoft.Xna.Framework.Graphics (in Microsoft.Xna.Framework.Graphics.dll)

Syntax

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

Parameters

Exceptions

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

Version Information

Silverlight

Supported in: 5

Platforms

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