Sparkle 0.0.1
Loading...
Searching...
No Matches
spk_sprite_renderer_2d.hpp
1#pragma once
2
3#include "structure/engine/2d/spk_component_2d.hpp"
4#include "structure/engine/2d/spk_entity_2d.hpp"
5#include "structure/engine/2d/spk_mesh_2d.hpp"
6#include "structure/graphics/painter/spk_mesh_painter.hpp"
7#include "structure/opengl/spk_sampler_object.hpp"
8#include "structure/opengl/spk_uniform_buffer_object.hpp"
9
10namespace spk
11{
17 {
18 private:
22 struct Painter : public spk::MeshPainter<Mesh2D>
23 {
24 private:
25 static spk::Lumina::Pipeline &_pipeline();
27 spk::OpenGL::SamplerObject &_textureSampler;
28 spk::OpenGL::UBO &_modelData;
29
30 public:
31 Painter();
32
33 void setTransform(const Transform2D &p_transform);
34 void setTexture(const spk::OpenGL::TextureObject *p_texture);
36 };
37
38 Transform2D::EditionContract _onOwnerTransformEditionContract;
39 Painter _painter;
40
41 void _onPaintEvent(spk::PaintEvent &p_event) override;
42
43 public:
48 explicit SpriteRenderer2D(const std::wstring &p_name);
49
51 void start() override;
56 void setMesh(const Mesh2D *p_mesh);
61 const Mesh2D *mesh() const;
66 void setTexture(const spk::OpenGL::TextureObject *p_texture);
72 };
73}
Component2D(const std::wstring &p_name)
Builds a 2D component with a name.
Definition spk_component_2d.cpp:9
Represents a drawable entity configured with pipeline attributes.
Definition spk_pipeline.hpp:324
Loads shader artifacts and orchestrates draw calls with strongly typed constants and attributes.
Definition spk_pipeline.hpp:38
Renderable mesh composed of 2D vertices.
Definition spk_mesh_2d.hpp:30
Base painter that renders a mesh through a Lumina pipeline.
Definition spk_mesh_painter.hpp:24
Binds a TextureObject to a uniform sampler location and texture unit.
Definition spk_sampler_object.hpp:18
CPU-staged 2D texture with activation and parameter controls.
Definition spk_texture_object.hpp:25
void start() override
Initializes rendering resources.
Definition spk_sprite_renderer_2d.cpp:49
void setMesh(const Mesh2D *p_mesh)
Sets the mesh to render.
Definition spk_sprite_renderer_2d.cpp:57
const spk::OpenGL::TextureObject * texture() const
Returns the current texture.
Definition spk_sprite_renderer_2d.cpp:72
const Mesh2D * mesh() const
Returns the current mesh.
Definition spk_sprite_renderer_2d.cpp:62
void setTexture(const spk::OpenGL::TextureObject *p_texture)
Sets the texture to sample.
Definition spk_sprite_renderer_2d.cpp:67
SpriteRenderer2D(const std::wstring &p_name)
Creates a sprite renderer component.
Definition spk_sprite_renderer_2d.cpp:44
Position, rotation, and scale component for 2D entities.
Definition spk_transform_2d.hpp:20
spk::ContractProvider::Contract EditionContract
Subscription contract type for transform edits.
Definition spk_transform_2d.hpp:23
Event emitted when a drawable region needs repainting.
Definition spk_paint_event.hpp:19