3#include "structure/graphics/painter/spk_mesh_painter.hpp"
4#include "structure/math/spk_vector2.hpp"
5#include "structure/opengl/spk_sampler_object.hpp"
6#include "structure/opengl/spk_texture_object.hpp"
7#include "structure/opengl/spk_vertex_buffer_object.hpp"
66 std::vector<Polygon> _polygons;
121 Builder &
insertRectangle(
const Vector2Int &p_anchor,
const Vector2UInt &p_size,
const Vector2 &p_uvAnchor,
const Vector2 &p_uvSize, PolygonOrder p_order = PolygonOrder::TriangleFanFromFirst)
123 const Vector2Int posA{p_anchor.
x, p_anchor.
y};
124 const Vector2Int posB{p_anchor.
x, p_anchor.
y +
static_cast<int>(p_size.
y)};
125 const Vector2Int posC{p_anchor.
x +
static_cast<int>(p_size.
x), p_anchor.
y +
static_cast<int>(p_size.
y)};
126 const Vector2Int posD{p_anchor.
x +
static_cast<int>(p_size.
x), p_anchor.
y};
128 const Vector2 uvA = p_uvAnchor;
129 const Vector2 uvB{p_uvAnchor.
x, p_uvAnchor.
y + p_uvSize.
y};
130 const Vector2 uvC{p_uvAnchor.
x + p_uvSize.
x, p_uvAnchor.
y + p_uvSize.
y};
131 const Vector2 uvD{p_uvAnchor.
x + p_uvSize.
x, p_uvAnchor.
y};
150 return insertRectangle(p_anchor, p_size, {0.0f, 0.0f}, {1.0f, 1.0f}, p_order);
161 return insertRectangle(p_extend.anchor, p_extend.size, {0.0f, 0.0f}, {1.0f, 1.0f}, p_order);
171 for (
const auto &poly : _polygons)
187 layout.addAttribute({0, Attribute::Type::Vector2Int});
188 layout.addAttribute({1, Attribute::Type::Vector2});
208 OpenGL::UBO &_modelData;
221 void setLayer(
const float &p_layer);
226 const float &
layer()
const;
const std::shared_ptr< spk::OpenGL::BufferSetObject > & bufferSet() const
Definition spk_mesh.hpp:338
IMesh()
Definition spk_mesh.hpp:170
void append(const Polygon &p_shape)
Appends a polygon and notifies subscribers.
Definition spk_mesh.hpp:270
IPolygon< TextureVertex > Polygon
Definition spk_mesh.hpp:34
Loads shader artifacts and orchestrates draw calls with strongly typed constants and attributes.
Definition spk_pipeline.hpp:38
MeshPainter(Lumina::Pipeline &p_pipeline)
Definition spk_mesh_painter.hpp:41
VertexBufferObject & vbo()
Access mutable VBO.
Definition spk_buffer_set_object.cpp:76
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
Layout & layout()
Access layout descriptor.
Definition spk_vertex_buffer_object.cpp:253
Builder()=default
Builds an empty builder.
Builder & insertQuad(const TextureVertex &p_a, const TextureVertex &p_b, const TextureVertex &p_c, const TextureVertex &p_d, PolygonOrder p_order=PolygonOrder::TriangleFanFromFirst)
Inserts a textured quad.
Definition spk_texture_painter.hpp:106
Builder & insertRectangleFullUV(const Vector2Int &p_anchor, const Vector2UInt &p_size, PolygonOrder p_order=PolygonOrder::TriangleFanFromFirst)
Inserts a rectangle using full [0,1] UV range.
Definition spk_texture_painter.hpp:148
Builder & insertRectangle(const Vector2Int &p_anchor, const Vector2UInt &p_size, const Vector2 &p_uvAnchor, const Vector2 &p_uvSize, PolygonOrder p_order=PolygonOrder::TriangleFanFromFirst)
Inserts a textured rectangle with explicit UVs.
Definition spk_texture_painter.hpp:121
Builder & insertTriangle(const TextureVertex &p_a, const TextureVertex &p_b, const TextureVertex &p_c)
Inserts a textured triangle.
Definition spk_texture_painter.hpp:91
Builder & clear()
Clears all stored polygons.
Definition spk_texture_painter.hpp:78
TextureMesh construct()
Builds a TextureMesh from stored polygons.
Definition spk_texture_painter.hpp:168
Builder & insertRectangleFullUV(const spk::Extend2D &p_extend, PolygonOrder p_order=PolygonOrder::TriangleFanFromFirst)
Inserts a rectangle from an extend using full UV range.
Definition spk_texture_painter.hpp:159
Mesh specialization for textured vertices.
Definition spk_texture_painter.hpp:42
Base::Polygon Polygon
Polygon type for textured vertices.
Definition spk_texture_painter.hpp:51
IMesh< TextureVertex > Base
Base mesh type.
Definition spk_texture_painter.hpp:47
void _configureBufferSet() const override
Configures the vertex buffer layout for textured vertices.
Definition spk_texture_painter.hpp:183
void setLayer(const float &p_layer)
Sets the layer value used during rendering.
Definition spk_texture_painter.cpp:23
const OpenGL::TextureObject * texture() const
Returns the current texture.
Definition spk_texture_painter.cpp:39
TexturePainter()
Builds a texture painter with its rendering pipeline.
Definition spk_texture_painter.cpp:14
void setTexture(const OpenGL::TextureObject *p_texture)
Sets the texture used for rendering.
Definition spk_texture_painter.cpp:34
const float & layer() const
Returns the current layer value.
Definition spk_texture_painter.cpp:29
Axis-aligned rectangle defined by an anchor point and size.
Definition spk_extend_2d.hpp:24
static IPolygon< TVertex > makeTriangle(const TVertex &p_a, const TVertex &p_b, const TVertex &p_c)
Creates a triangle polygon.
Definition spk_polygon.hpp:46
static IPolygon< TVertex > makeQuad(const TVertex &p_a, const TVertex &p_b, const TVertex &p_c, const TVertex &p_d, const PolygonOrder p_order=PolygonOrder::TriangleFanFromFirst)
Creates a quad polygon.
Definition spk_polygon.hpp:60
TType x
X component.
Definition spk_vector2.hpp:44
TType y
Y component.
Definition spk_vector2.hpp:48
Describes a vertex attribute entry in the layout.
Definition spk_vertex_buffer_object.hpp:38
Vertex containing a position and texture coordinates.
Definition spk_texture_painter.hpp:20
Vector2 uv
Texture coordinates.
Definition spk_texture_painter.hpp:28
Vector2Int pos
Vertex position in integer coordinates.
Definition spk_texture_painter.hpp:24