CommandBuffer

Inherited: Object

Description

The CommandBuffer class represents a command buffer used in a graphics rendering pipeline. It provides methods for issuing rendering commands, setting global parameters, and managing textures.

Public Methods

void

beginDebugMarker (const char * name)

void

clearRenderTarget (bool clearColor = true, const Vector4 & color = Vector4(0.0f), bool clearDepth = true, float depth = 1.0f)

void

disableScissor ()

void

dispatchCompute (ComputeInstance * shader, int32_t groupsX, int32_t groupsY, int32_t groupsZ)

void

drawMesh (const Matrix4 & transform, Mesh * mesh, int sub, int layer = CommandBuffer::DEFAULT, MaterialInstance * material = nullptr)

void

drawMeshInstanced (const Matrix4 * transform, int count, Mesh * mesh, int sub, int layer = CommandBuffer::DEFAULT, MaterialInstance * material = nullptr)

void

enableScissor (int32_t x, int32_t y, int32_t width, int32_t height)

void

endDebugMarker ()

Matrix4

projection () const

void

resetViewProjection ()

void

setColor (const Vector4 & color)

void

setGlobalTexture (const char * name, Texture * texture)

void

setGlobalValue (const char * name, const Variant & value)

void

setMaterialId (int id)

void

setObjectId (int id)

void

setRenderTarget (RenderTarget * target, int level = 0)

void

setScreenProjection (float x = -0.5f, float y = -0.5f, float width = 0.5f, float height = 0.5f)

void

setViewProjection (const Matrix4 & view, const Matrix4 & projection)

void

setViewport (int32_t x, int32_t y, int32_t width, int32_t height)

Texture *

texture (const char * name) const

Matrix4

view () const

Vector2

viewport () const

Static Methods

Vector4

idToColor (int id)

bool

isInited ()

Methods Description

void CommandBuffer::beginDebugMarker (char * name)

Begins a debug marker with the specified name.


void CommandBuffer::clearRenderTarget (bool clearColor = true, Vector4 & color = Vector4(0.0f), bool clearDepth = true, float depth = 1.0f)

Clears the render target with the specified color and depth values. Flag clearColor indicating whether to clear the color buffer. Flag clearDepth indicating whether to clear the depth buffer.


void CommandBuffer::disableScissor ()

Disables scissor testing.


void CommandBuffer::dispatchCompute (ComputeInstance * shader, int32_t groupsX, int32_t groupsY, int32_t groupsZ)

Dispatches a compute shader with the specified workgroup dimensions. Parameters groupsX, groupsY and groupsZ alows to specify a size of workgroup in each demension.


void CommandBuffer::drawMesh (Matrix4 & transform, Mesh * mesh, int sub, int layer = CommandBuffer::DEFAULT, MaterialInstance * material = nullptr)

Draws a mesh with the specified sub mesh index in the transform location with assigned material, and rendering layer.


void CommandBuffer::drawMeshInstanced (Matrix4 * transform, int count, Mesh * mesh, int sub, int layer = CommandBuffer::DEFAULT, MaterialInstance * material = nullptr)

Draws the same mesh multiple times using GPU instancing. GPU will draw this mesh with the specified sub mesh index in different transform locations with assigned material, and rendering layer. Parameter count specifies the number of instances to draw.


void CommandBuffer::enableScissor (int32_t x, int32_t y, int32_t width, int32_t height)

Enables scissor testing with the specified parameters. Parameters x and y represents scissor coordinates. width and height scissor dimensions.


void CommandBuffer::endDebugMarker ()

Ends the current debug marker.


Vector4 CommandBuffer::idToColor (int id)

Converts a 32-bit id to a Vector4 color.


bool CommandBuffer::isInited ()

Returns true if the CommandBuffer is initialized; otherwise, false.


Matrix4 CommandBuffer::projection () const

Returns current projection matrix.


void CommandBuffer::resetViewProjection ()

Resets the view and projection matrices to their saved values.


void CommandBuffer::setColor (Vector4 & color)

Sets the color for rendering commands.


void CommandBuffer::setGlobalTexture (char * name, Texture * texture)

Sets a global texture based on its name.


void CommandBuffer::setGlobalValue (char * name, Variant & value)

Sets a global value based on its name.


void CommandBuffer::setMaterialId (int id)

Sets the material id for rendering commands.


void CommandBuffer::setObjectId (int id)

Sets the object id for rendering commands.


void CommandBuffer::setRenderTarget (RenderTarget * target, int level = 0)

Sets the render target for subsequent rendering commands. Parameter level specifies the Mipmap level.


void CommandBuffer::setScreenProjection (float x = -0.5f, float y = -0.5f, float width = 0.5f, float height = 0.5f)

Sets the screen projection matrix. Parameters x and y represents screen coordinates. width and height screen dimensions.


void CommandBuffer::setViewProjection (Matrix4 & view, Matrix4 & projection)

Sets the view and projection matrices.


void CommandBuffer::setViewport (int32_t x, int32_t y, int32_t width, int32_t height)

Sets the viewport dimensions. Parameters x and y represents viewport coordinates. width and height viewport dimensions.

See also viewport().


:ref:`Texture<api_Texture>`* CommandBuffer::texture (char * name) const

Retrieves a global texture based on its name.


Matrix4 CommandBuffer::view () const

Returns current view matrix.


Vector2 CommandBuffer::viewport () const

Returns Vector2 representing the viewport dimensions.

See also setViewport().