le2d v0.4.6
2D game engine framework
 
Loading...
Searching...
No Matches
figure.hpp
Go to the documentation of this file.
1#pragma once
3#include "le2d/geometry.hpp"
5
6namespace le::drawable {
8class IFigure : public IDrawPrimitive {};
9
11template <std::derived_from<IGeometry> Type>
12class FigureBase : public Type, public IFigure {
13 public:
14 using Type::Type;
15
16 [[nodiscard]] auto to_primitive() const -> Primitive final {
17 return Primitive{
18 .vertices = this->get_vertices(),
19 .indices = this->get_indices(),
20 .topology = this->get_topology(),
21 .texture = texture,
22 };
23 }
24
26};
27
29template <std::derived_from<IGeometry> Type>
30class Figure : public SingleDrawPrimitive<FigureBase<Type>> {
31 public:
33 [[nodiscard]] auto bounding_rect() const -> kvf::Rect<> { return vertex_bounds(this->to_primitive().vertices, this->transform.to_model()); }
34};
35
37template <std::derived_from<IGeometry> Type>
38class InstancedFigure : public InstancedDrawPrimitive<FigureBase<Type>> {};
39} // namespace le::drawable
Interface for drawable primitives.
Definition draw_primitive.hpp:7
Interface for drawable texture.
Definition texture.hpp:15
Base class for Draw Primitives using a vector of Render Instances.
Definition draw_primitive.hpp:24
Base class for Draw Primitives using a single Render Instance.
Definition draw_primitive.hpp:17
Base class for drawable Figure.
Definition figure.hpp:12
ITextureBase const * texture
Definition figure.hpp:25
auto to_primitive() const -> Primitive final
Definition figure.hpp:16
Base class for Figures using a single Render Instance.
Definition figure.hpp:30
auto bounding_rect() const -> kvf::Rect<>
Definition figure.hpp:33
Interface for drawable figures.
Definition figure.hpp:8
Base class for Figures using a vector of Render Instances.
Definition figure.hpp:38
Definition texture.hpp:9
Definition figure.hpp:6
auto vertex_bounds(std::span< Vertex const > vertices, glm::mat4 const &model) -> kvf::Rect<>
Draw primitive.
Definition primitive.hpp:10
std::span< Vertex const > vertices
Definition primitive.hpp:11
Transform transform
Definition render_instance.hpp:8
auto to_model() const -> glm::mat4