nCine::RenderCommand class

Holds all the state needed to issue a single draw call.

Bundles the material, geometry, model transformation and sort keys for one renderable. The render queue sorts commands by their material sort key to minimize state changes, optionally merges them via RenderBatcher, and finally calls Issue() to bind the state and draw.

Public types

enum class Type { Unspecified = 0, Sprite, MeshSprite, TileMap, Particle, Lighting, Text, ImGui, Count }
Command type.

Public static functions

static auto CalculateDepth(std::uint16_t layer, float nearClip, float farClip) -> float
Calculates the Z-depth of a command layer using the specified near and far planes.

Constructors, destructors, conversion operators

RenderCommand(Type type) explicit
RenderCommand()

Public functions

auto GetInstanceCount() const -> std::int32_t
Returns the number of instances collected in the command or zero if instancing is not used.
void SetInstanceCount(std::int32_t numInstances)
Sets the number of instances collected in the command.
auto GetBatchSize() const -> std::int32_t
Returns the number of elements collected by the command or zero if it's not a batch.
void SetBatchSize(std::int32_t batchSize)
Sets the number of batch elements collected by the command.
auto GetLayer() const -> std::uint16_t
Returns the drawing layer for this command.
void SetLayer(std::uint16_t layer)
Sets the drawing layer for this command.
auto GetVisitOrder() const -> std::uint16_t
Returns the visit order index for this command.
void SetVisitOrder(std::uint16_t visitOrder)
Sets the visit order index for this command.
auto GetMaterialSortKey() const -> std::uint64_t
Returns the material sort key for the queue.
auto GetLowerMaterialSortKey() const -> std::uint32_t
Returns the lower part of the material sort key, used for batch splitting logic.
void CalculateMaterialSortKey()
Calculates the material sort key for the queue.
auto GetIdSortKey() const -> std::uint32_t
Returns the id based secondary sort key for the queue.
void SetIdSortKey(std::uint32_t idSortKey)
Sets the id based secondary sort key for the queue.
void Issue()
Binds the command state and issues the draw call.
auto GetType() const -> Type
Returns the command type (for profiling purposes).
void SetType(Type type)
Sets the command type (for profiling purposes).
void SetScissor(Recti scissorRect)
Sets the scissor rectangle for this command.
void SetScissor(GLint x, GLint y, GLsizei width, GLsizei height)
Sets the scissor rectangle for this command.
auto GetTransformation() const -> const Matrix4x4f&
Returns the model transformation matrix.
void SetTransformation(const Matrix4x4f& modelMatrix)
Sets the model transformation matrix and marks it for re-committing.
auto GetMaterial() const -> const Material&
Returns the material (read-only).
auto GetGeometry() const -> const Geometry&
Returns the geometry (read-only).
auto GetMaterial() -> Material&
Returns the material.
auto GetGeometry() -> Geometry&
Returns the geometry.
void CommitNodeTransformation()
Commits the model matrix uniform block.
void CommitCameraTransformation()
Commits the projection and view matrix uniforms.
void CommitAll()
Calls all the commit methods except the camera uniforms commit.

Enum documentation

enum class nCine::RenderCommand::Type

Command type.

Its sole purpose is to allow separated profiling counters in the RenderStatistics class.

Enumerators
Unspecified

Unspecified or non-profiled command

Sprite

Sprite draw command

MeshSprite

Mesh sprite draw command

TileMap

Tile map draw command

Particle

Particle draw command

Lighting

Lighting draw command

Text

Text draw command

ImGui

ImGui draw command

Count

Number of command types