Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
Engine::SpriteRenderer Struct Reference

Component that renders a textured 2D quad (sprite) on an entity. More...

#include <SpriteRenderer.hpp>

Public Attributes

std::string texturePath
 Path to the sprite texture asset (PNG, JPG, TGA).
glm::vec4 color = { 1.0f, 1.0f, 1.0f, 1.0f }
 RGBA tint multiplied with the sampled texture colour.
bool flipX = false
 Flip UV horizontally (mirrors sprite around the vertical axis).
bool flipY = false
 Flip UV vertically (mirrors sprite around the horizontal axis).
int sortOrder = 0
 Depth-sorting order relative to other sprites. Lower values render behind higher values.
uint32_t _managedMeshId = 0
 GPU mesh ID of the managed unit quad (0 = not yet created).
uint32_t _managedMatId = 0
 GPU material ID of the managed sprite material (0 = not yet created).
std::string _loadedTexturePath
 The texture path that was last uploaded — used to detect dirty texture changes.
bool _lastFlipX = false
 The flip state that was last applied — used to detect changes requiring mesh rebuild.
bool _lastFlipY = false
 The flip state that was last applied — used to detect changes requiring mesh rebuild.
int _lastSortOrder = 0
 sortOrder value that was last applied.
bool _dirty = true
 Whether this sprite needs full setup on the next update.

Detailed Description

Component that renders a textured 2D quad (sprite) on an entity.

The SpriteSystem manages a unit quad Mesh and an "Unlit" Material per sprite entity so the existing RenderSystem picks them up automatically. Use with an orthographic Camera for traditional 2D game rendering, or combine with a perspective Camera for 3D billboards.

Flip is handled via UV remapping in the sprite.vert shader — flipping does not affect the entity's Transform, Collider, or any physics component.

Sort order is stored here for depth hint purposes. The SpriteSystem automatically adjusts Transform.position.z by sortOrder * 0.0001f each frame so overlapping sprites layer correctly. Users should keep Transform.z at 0 and use sortOrder for layering.

Member Data Documentation

◆ _dirty

bool Engine::SpriteRenderer::_dirty = true

Whether this sprite needs full setup on the next update.

◆ _lastFlipX

bool Engine::SpriteRenderer::_lastFlipX = false

The flip state that was last applied — used to detect changes requiring mesh rebuild.

◆ _lastFlipY

bool Engine::SpriteRenderer::_lastFlipY = false

The flip state that was last applied — used to detect changes requiring mesh rebuild.

◆ _lastSortOrder

int Engine::SpriteRenderer::_lastSortOrder = 0

sortOrder value that was last applied.

◆ _loadedTexturePath

std::string Engine::SpriteRenderer::_loadedTexturePath

The texture path that was last uploaded — used to detect dirty texture changes.

◆ _managedMatId

uint32_t Engine::SpriteRenderer::_managedMatId = 0

GPU material ID of the managed sprite material (0 = not yet created).

◆ _managedMeshId

uint32_t Engine::SpriteRenderer::_managedMeshId = 0

GPU mesh ID of the managed unit quad (0 = not yet created).

◆ color

glm::vec4 Engine::SpriteRenderer::color = { 1.0f, 1.0f, 1.0f, 1.0f }

RGBA tint multiplied with the sampled texture colour.

◆ flipX

bool Engine::SpriteRenderer::flipX = false

Flip UV horizontally (mirrors sprite around the vertical axis).

◆ flipY

bool Engine::SpriteRenderer::flipY = false

Flip UV vertically (mirrors sprite around the horizontal axis).

◆ sortOrder

int Engine::SpriteRenderer::sortOrder = 0

Depth-sorting order relative to other sprites. Lower values render behind higher values.

◆ texturePath

std::string Engine::SpriteRenderer::texturePath

Path to the sprite texture asset (PNG, JPG, TGA).


The documentation for this struct was generated from the following file: