Jazz2::UI::Canvas class

Canvas.

Base drawing surface for on-screen UI rendering. It collects textured and solid rectangle draw calls as render commands and submits them to the render queue, also providing alignment helpers and palette-based recoloring.

Base classes

class nCine::SceneNode
Base node of the scene graph transformation hierarchy.

Derived classes

class HUD
Player HUD.
class InGameConsole
In-game console.
class MpInGameCanvasLayer
In-game canvas on sprite layer for multiplayer.
class MpInGameLobby
In-game lobby screen for multiplayer.

Public static functions

static auto ApplyAlignment(Alignment align, Vector2f vec, Vector2f size) -> Vector2f
Applies alignment settings to a given position vector.

Constructors, destructors, conversion operators

Canvas()
Creates a new instance.

Public functions

void OnUpdate(float timeMult) override
Called every frame to update the node state.
auto OnDraw(RenderQueue& renderQueue) -> bool override
Called when the node needs to be drawn, returning true if a command was added.
void DrawTexture(const Texture& texture, Vector2f pos, std::uint16_t z, Vector2f size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending = false, float angle = 0.0f, std::int32_t paletteOffset = -1)
Draws a textured rectangle.
void DrawTextureWithPalette(const Texture& texture, const Texture& palette, Vector2f pos, std::uint16_t z, Vector2f size, const Vector4f& texCoords, const Colorf& color, float paletteOffset = 0.0f)
Draws an indexed textured rectangle recolored through a palette texture (PaletteRemap shader).
void DrawSolid(Vector2f pos, std::uint16_t z, Vector2f size, const Colorf& color, bool additiveBlending = false)
Draws a solid rectangle.
auto RentRenderCommand() -> RenderCommand*
Rents a render command for rendering on the canvas.
void DrawRenderCommand(RenderCommand* command)
Draws a raw render command.

Public variables

Vector2i ViewSize
View size of the canvas.
float AnimTime
Animation time of the canvas.

Protected static variables

static float AnimTimeMultiplier constexpr
Multiplier of game time for canvas rendering.

Function documentation

void Jazz2::UI::Canvas::DrawTexture(const Texture& texture, Vector2f pos, std::uint16_t z, Vector2f size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending = false, float angle = 0.0f, std::int32_t paletteOffset = -1)

Draws a textured rectangle.

paletteOffset >= 0 marks the texture as indexed (palette index in the red channel), recolored at draw time through the shared palette texture at that offset; -1 = plain RGBA.

void Jazz2::UI::Canvas::DrawTextureWithPalette(const Texture& texture, const Texture& palette, Vector2f pos, std::uint16_t z, Vector2f size, const Vector4f& texCoords, const Colorf& color, float paletteOffset = 0.0f)

Draws an indexed textured rectangle recolored through a palette texture (PaletteRemap shader).

The palette offset is the flat index of the first color in the palette texture (0 = the first row/palette).