le2d
v0.4.6
2D game engine framework
Loading...
Searching...
No Matches
figure.hpp
Go to the documentation of this file.
1
#pragma once
2
#include "
le2d/drawable/draw_primitive.hpp
"
3
#include "
le2d/geometry.hpp
"
4
#include "
le2d/vertex_bounds.hpp
"
5
6
namespace
le::drawable
{
8
class
IFigure
:
public
IDrawPrimitive
{};
9
11
template
<std::derived_from<IGeometry> Type>
12
class
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
25
ITextureBase
const
*
texture
{};
26
};
27
29
template
<std::derived_from<IGeometry> Type>
30
class
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
37
template
<std::derived_from<IGeometry> Type>
38
class
InstancedFigure
:
public
InstancedDrawPrimitive
<FigureBase<Type>> {};
39
}
// namespace le::drawable
le::IDrawPrimitive
Interface for drawable primitives.
Definition
draw_primitive.hpp:7
le::ITextureBase
Interface for drawable texture.
Definition
texture.hpp:15
le::InstancedDrawPrimitive
Base class for Draw Primitives using a vector of Render Instances.
Definition
draw_primitive.hpp:24
le::SingleDrawPrimitive
Base class for Draw Primitives using a single Render Instance.
Definition
draw_primitive.hpp:17
le::drawable::FigureBase
Base class for drawable Figure.
Definition
figure.hpp:12
le::drawable::FigureBase::texture
ITextureBase const * texture
Definition
figure.hpp:25
le::drawable::FigureBase::to_primitive
auto to_primitive() const -> Primitive final
Definition
figure.hpp:16
le::drawable::Figure
Base class for Figures using a single Render Instance.
Definition
figure.hpp:30
le::drawable::Figure::bounding_rect
auto bounding_rect() const -> kvf::Rect<>
Definition
figure.hpp:33
le::drawable::IFigure
Interface for drawable figures.
Definition
figure.hpp:8
le::drawable::InstancedFigure
Base class for Figures using a vector of Render Instances.
Definition
figure.hpp:38
draw_primitive.hpp
geometry.hpp
kvf
Definition
texture.hpp:9
le::drawable
Definition
figure.hpp:6
le::vertex_bounds
auto vertex_bounds(std::span< Vertex const > vertices, glm::mat4 const &model) -> kvf::Rect<>
le::Primitive
Draw primitive.
Definition
primitive.hpp:10
le::Primitive::vertices
std::span< Vertex const > vertices
Definition
primitive.hpp:11
le::RenderInstance::transform
Transform transform
Definition
render_instance.hpp:8
le::Transform::to_model
auto to_model() const -> glm::mat4
vertex_bounds.hpp
lib
include
le2d
drawable
figure.hpp
Generated by
1.9.8