Microsoft DirectX 8.1 (Visual Basic)

Direct3DDevice8.SetRenderTarget

Sets a new color buffer, depth buffer, or both for the device.

object.SetRenderTarget( _ 
    NewRenderTarget As Direct3DSurface8, _ 
    NewDepthStencil As Direct3DSurface8, _
    Reserved )

Parts

object
Object expression that resolves to a Direct3DDevice8 object.
NewRenderTarget
New color buffer. If Nothing, the existing color buffer is retained. If this parameter is not Nothing, the reference count on the new render target is incremented. Devices always have to be associated with a color buffer.

The new render target surface must have at least D3DUSAGE_RENDERTARGET specified.

NewDepthStencil
New depth-stencil buffer. If a depth-stencil buffer exists, it is released. If this parameter is not Nothing, the reference count on the new depth-stencil buffer surface is incremented. Applications can change the render target without changing the depth buffer by passing in the Direct3DSurface8 object returned by Direct3DDevice8.GetDepthStencilSurface.

The new depth-stencil surface must have at least D3DUSAGE_DEPTHSTENCIL and D3DPOOL_DEFAULT specified.

Reserved
Reserved. Must be set to 0.

Error Codes

If the method fails, an error is raised and Err.Number may be set to D3DERR_INVALIDCALL if NewRenderTarget or NewDepthStencil are not Nothing and invalid, or if the new depth buffer is smaller than the new or retained color buffer.

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

Once a color buffer and a depth-stencil surface have been associated with the same device by this method, they are said to be paired.

The previous depth-stencil surface's contents persist after a call to SetRenderTarget to disassociate the previous depth-stencil surface from the device. If the surface is re-associated with the device, then the contents of the surface will be unchanged, providing the color buffer to which the new depth-stencil surface is being paired is the same size and format as the color buffer to which the depth-stencil surface was most recently paired.

See Also

Direct3DDevice8.CreateDepthStencilSurface, Direct3DDevice8.GetDepthStencilSurface