Sparkle 0.0.1
Loading...
Searching...
No Matches
spk_mesh_painter.hpp
1#pragma once
2
3#include "structure/geometry/spk_mesh.hpp"
4#include "structure/lumina/spk_pipeline.hpp"
5
6#include <iostream>
7
8namespace spk
9{
22 template <typename TMeshType>
24 {
25 public:
29 using Mesh = TMeshType;
30
31 private:
32 Lumina::Pipeline &_pipeline;
34 const Mesh *_mesh = nullptr;
35
36 protected:
41 explicit MeshPainter(Lumina::Pipeline &p_pipeline) :
42 _pipeline(p_pipeline),
43 _object(_pipeline.createObject())
44 {
45 }
46
52 {
53 return (_object);
54 }
55
61 {
62 return (_object);
63 }
64
65 public:
70 virtual void setMesh(const Mesh *p_mesh)
71 {
72 _mesh = p_mesh;
73
74 if (_mesh == nullptr)
75 {
76 return;
77 }
78
79 _object.setBufferSet(_mesh->bufferSet());
80 }
81
86 const Mesh *mesh() const
87 {
88 return (_mesh);
89 }
90
94 void render()
95 {
96 if (_mesh == nullptr)
97 {
98 return;
99 }
100
101 if (_mesh->indexes().size() == 0)
102 {
103 return;
104 }
105
106 _mesh->synchronize();
107 _object.render();
108 }
109 };
110}
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
Lumina::Pipeline::Object & _objectHandle()
Returns the render object handle.
Definition spk_mesh_painter.hpp:51
const Mesh * mesh() const
Returns the currently bound mesh.
Definition spk_mesh_painter.hpp:86
TMeshType Mesh
Mesh type handled by the painter.
Definition spk_mesh_painter.hpp:29
const Lumina::Pipeline::Object & _objectHandle() const
Returns the render object handle.
Definition spk_mesh_painter.hpp:60
virtual void setMesh(const Mesh *p_mesh)
Sets the mesh to render.
Definition spk_mesh_painter.hpp:70
MeshPainter(Lumina::Pipeline &p_pipeline)
Builds a mesh painter bound to a pipeline.
Definition spk_mesh_painter.hpp:41
void render()
Renders the current mesh when available.
Definition spk_mesh_painter.hpp:94