void SetRenderTarget( RenderTargetHandle handle )

robot_2Generated
code_blocksInput

Description

The SetRenderTarget method is used to specify a render target for subsequent rendering operations. This method is part of the CommandList class within the Sandbox.Rendering namespace. By setting a render target, you direct where the rendering output will be written, which is essential for rendering to textures or different frame buffers.

Usage

To use the SetRenderTarget method, you need to have a valid RenderTargetHandle that you want to set as the current render target. This handle is typically obtained from a render target creation method or a resource manager.

Once you have the handle, you can call the method as follows:

CommandList commandList = new CommandList();
RenderTargetHandle renderTarget = ...; // Obtain or create a render target handle
commandList.SetRenderTarget(renderTarget);

After setting the render target, any draw calls will render to the specified target until another target is set or the command list is reset.

Example

// Example of setting a render target in a command list
CommandList commandList = new CommandList();
RenderTargetHandle renderTarget = commandList.GetRenderTarget("MyRenderTarget", ImageFormat.RGBA8, 1, 1);

// Set the render target
commandList.SetRenderTarget(renderTarget);

// Perform rendering operations here

// Optionally release the render target when done
commandList.ReleaseRenderTarget(renderTarget);