static void Clear( Color color, bool clearColor, bool clearDepth, bool clearStencil )
static void Clear( bool clearColor, bool clearDepth )

book_4_sparkGenerated
code_blocksInput

Description

The Clear method in the Sandbox.Graphics class is used to clear the current render target with specified options. This method allows you to clear the color, depth, and stencil buffers of the render target, which is essential for preparing the render target for new drawing operations.

Usage

To use the Clear method, you need to specify the color to clear with and whether to clear the color, depth, and stencil buffers. This is typically done at the beginning of a rendering pass to ensure that the previous frame's data does not interfere with the current frame.

Parameters:

  • color: A Color object representing the color to clear the render target with.
  • clearColor: A bool indicating whether the color buffer should be cleared.
  • clearDepth: A bool indicating whether the depth buffer should be cleared.
  • clearStencil: A bool indicating whether the stencil buffer should be cleared.

Example

// Example of using the Clear method
Color clearColor = new Color(0, 0, 0, 1); // Black color
bool shouldClearColor = true;
bool shouldClearDepth = true;
bool shouldClearStencil = false;

// Clear the render target with the specified parameters
Graphics.Clear(clearColor, shouldClearColor, shouldClearDepth, shouldClearStencil);