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
SpriteRenderer.hpp
Go to the documentation of this file.
1#pragma once
2#include <glm/glm.hpp>
3#include <string>
4#include "core/EngineAPI.hpp"
5
6namespace Engine {
7
23 // [ReflectClass]
26 // [ReflectField]
27 std::string texturePath;
28
30 // [ReflectField]
31 glm::vec4 color = { 1.0f, 1.0f, 1.0f, 1.0f };
32
34 // [ReflectField]
35 bool flipX = false;
36
38 // [ReflectField]
39 bool flipY = false;
40
42 // [ReflectField]
43 int sortOrder = 0;
44
45 // ---- Internal runtime state (not reflected, not serialized) ----
46
48 uint32_t _managedMeshId = 0;
49
51 uint32_t _managedMatId = 0;
52
54 std::string _loadedTexturePath;
55
57 bool _lastFlipX = false;
58
60 bool _lastFlipY = false;
61
64
66 bool _dirty = true;
67 };
68
69} // namespace Engine
70
72REGISTER_COMPONENT(Engine::SpriteRenderer, "Rendering & Lights/Sprite Renderer");
#define REGISTER_COMPONENT(Type, MenuPath)
Definition ComponentReflection.hpp:156
#define ENGINE_API
Definition EngineAPI.hpp:10
Definition Application.hpp:16
Component that renders a textured 2D quad (sprite) on an entity.
Definition SpriteRenderer.hpp:24
uint32_t _managedMatId
GPU material ID of the managed sprite material (0 = not yet created).
Definition SpriteRenderer.hpp:51
std::string texturePath
Path to the sprite texture asset (PNG, JPG, TGA).
Definition SpriteRenderer.hpp:27
int sortOrder
Depth-sorting order relative to other sprites. Lower values render behind higher values.
Definition SpriteRenderer.hpp:43
bool _lastFlipY
The flip state that was last applied — used to detect changes requiring mesh rebuild.
Definition SpriteRenderer.hpp:60
uint32_t _managedMeshId
GPU mesh ID of the managed unit quad (0 = not yet created).
Definition SpriteRenderer.hpp:48
std::string _loadedTexturePath
The texture path that was last uploaded — used to detect dirty texture changes.
Definition SpriteRenderer.hpp:54
bool flipY
Flip UV vertically (mirrors sprite around the horizontal axis).
Definition SpriteRenderer.hpp:39
bool _lastFlipX
The flip state that was last applied — used to detect changes requiring mesh rebuild.
Definition SpriteRenderer.hpp:57
bool _dirty
Whether this sprite needs full setup on the next update.
Definition SpriteRenderer.hpp:66
bool flipX
Flip UV horizontally (mirrors sprite around the vertical axis).
Definition SpriteRenderer.hpp:35
glm::vec4 color
RGBA tint multiplied with the sampled texture colour.
Definition SpriteRenderer.hpp:31
int _lastSortOrder
sortOrder value that was last applied.
Definition SpriteRenderer.hpp:63