Device.SetRenderTarget(Int32,Surface) Method (Microsoft.DirectX.Direct3D)
Sets a new color buffer for a device.
Visual Basic Public Sub SetRenderTarget( _
ByVal renderTargetIndex As Integer, _
ByVal renderTarget As Surface _
C# public void SetRenderTarget(
JScript public function SetRenderTarget(
renderTargetIndex : int,
renderTarget : Surface
Index of the render target. See Remarks.
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.
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.
- 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. For more information, see Manager.CheckDepthStencilMatch.
- 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 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.
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.