|
Engine
Raylib based game framework
|
Draws all entities with Sprite and Transform components. More...
#include <Renderer.hpp>
Public Member Functions | |
| void | Init (Registry ®istry, const float virtualWidth, const float virtualHeight) |
| Initialises the renderer and registers sprite change callbacks. | |
Static Public Member Functions | |
| static bool | SetSprite (const Entity entity, const Component::Sprite &sprite) |
| Assigns or replaces the Sprite component on an entity. | |
| static void | RemoveSprite (const Entity entity) |
| Removes the Sprite component from an entity. | |
Public Attributes | |
| Camera2D | camera |
Friends | |
| class | Engine |
Draws all entities with Sprite and Transform components.
Manages a sorted sprite pool and a 2D camera. Sprites are sorted by layer then by texture ID so draw calls are batched as much as possible. Entities missing a valid texture are rendered with a purple/black checkerboard placeholder until one is assigned.
The camera is public so scenes can manipulate it directly.
| void Renderer::Init | ( | Registry & | registry, |
| const float | virtualWidth, | ||
| const float | virtualHeight ) |
Initialises the renderer and registers sprite change callbacks.
Called automatically by the Engine constructor. Registers OnConstruct, OnUpdate, and OnDestroy callbacks on Component::Sprite so the sprite pool is re-sorted whenever the set of sprites changes.
| registry | Registry to watch for sprite changes |
| virtualWidth | Width of the virtual canvas in pixels |
| virtualHeight | Height of the virtual canvas in pixels |
|
static |
Removes the Sprite component from an entity.
Does nothing if the entity does not have a sprite.
| entity | Target entity |
|
static |
Assigns or replaces the Sprite component on an entity.
Returns false and leaves the entity unchanged if the sprite's texture is invalid.
| entity | Target entity |
| sprite | Sprite to assign |