Device.SetRenderTarget Method

Language:

Sets a new color buffer for a device.

Definition

Visual Basic Public Sub SetRenderTarget( _
    ByVal renderTargetIndex As Integer, _
    ByVal renderTarget As Surface _
)
C# public void SetRenderTarget(
    int renderTargetIndex,
    Surface renderTarget
);
C++ public:
void SetRenderTarget(
    int renderTargetIndex,
    SurfacerenderTarget
);
JScript public function SetRenderTarget(
    renderTargetIndex : int,
    renderTarget : Surface
);

Parameters

renderTargetIndex System.Int32
Index of the render target. See Remarks.
renderTarget Microsoft.DirectX.Direct3D.Surface
New color buffer. If set to null, the color buffer for the corresponding param_Int32_renderTargetIndex is disabled. Devices must always be associated with a color buffer.

The new render-target surface must have at least RenderTarget specified.

Remarks

The device can support multiple render targets. The number of render targets supported by a device is contained in Caps.NumberSimultaneousRts.

Some hardware tests the compatibility of the depth stencil buffer with the color buffer. If this is done, it is done only in a debug build.

The following restrictions apply when using this method.

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

Cube textures differ from other surfaces in that they are collections of surfaces. To call Device.SetRenderTarget with a cube texture, select an individual face using CubeTexture.GetCubeMapSurface and pass the resulting surface to Device.SetRenderTarget.

Exceptions
InvalidCallException The method call is invalid. Either param_Surface_renderTarget = null and param_Int32_renderTargetIndex = 0, or param_Surface_renderTarget != null and the render target is invalid.


Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center