libdonut  2.3.2
Application framework for cross-platform game development in C++20
TexturedQuad.hpp
Go to the documentation of this file.
1 #ifndef DONUT_GRAPHICS_TEXTURED_QUAD_HPP
2 #define DONUT_GRAPHICS_TEXTURED_QUAD_HPP
3 
5 #include <donut/math.hpp>
6 
7 #include <array> // std::array
8 #include <cstdint> // std::int32_t
9 
10 namespace donut::graphics {
11 
18 struct TexturedQuad {
24  struct Vertex {
25  vec2 coordinates;
26  };
27 
34  struct Instance {
37  vec4 tintColor;
38  };
39 
42 
45 
48 
50  static constexpr std::array<Vertex, 4> VERTICES{{
51  {.coordinates{0.0f, 0.0f}},
52  {.coordinates{0.0f, 1.0f}},
53  {.coordinates{1.0f, 0.0f}},
54  {.coordinates{1.0f, 1.0f}},
55  }};
56 
57  static constexpr std::int32_t TEXTURE_UNIT = 0;
58  static constexpr std::int32_t TEXTURE_UNIT_COUNT = 1;
59 
64 };
65 
66 } // namespace donut::graphics
67 
68 #endif
Generic abstraction of a GPU vertex array object and its associated buffers.
Definition: Mesh.hpp:226
Definition: Buffer.hpp:7
MeshBufferUsage
Hint to the graphics driver implementation regarding the intended access pattern of a particular GPU ...
Definition: Mesh.hpp:44
MeshPrimitiveType
Specification of which kind of graphical primitive is defined by an associated sequence of vertices i...
Definition: Mesh.hpp:60
@ TRIANGLE_STRIP
Each point, except the first two, forms a filled triangle with the previous two points.
Data layout for the attributes of a single instance of the mesh.
Definition: TexturedQuad.hpp:34
vec4 textureOffsetAndScale
Texture offset (xy) and texture scale (zw) to apply to the texture coordinates before sampling the te...
Definition: TexturedQuad.hpp:36
mat3 transformation
Transformation to apply to the vertex positions.
Definition: TexturedQuad.hpp:35
vec4 tintColor
Tint color to use when rendering.
Definition: TexturedQuad.hpp:37
Data layout for the attributes of a single vertex of the mesh.
Definition: TexturedQuad.hpp:24
vec2 coordinates
Shared vertex position and texture coordinates.
Definition: TexturedQuad.hpp:25
Square 2D mesh for textured rendering.
Definition: TexturedQuad.hpp:18
static constexpr std::int32_t TEXTURE_UNIT_COUNT
Total number of texture units required to render a textured quad.
Definition: TexturedQuad.hpp:58
static constexpr MeshPrimitiveType PRIMITIVE_TYPE
The type of 3D primitives represented by the mesh vertices.
Definition: TexturedQuad.hpp:47
static constexpr std::int32_t TEXTURE_UNIT
Main texture unit index to use in the shader.
Definition: TexturedQuad.hpp:57
Mesh< Vertex, NoIndex, Instance > mesh
Mesh data stored on the GPU.
Definition: TexturedQuad.hpp:63
static constexpr MeshBufferUsage VERTICES_USAGE
Hint regarding the intended memory access pattern of the vertex buffer.
Definition: TexturedQuad.hpp:41
static constexpr std::array< Vertex, 4 > VERTICES
The constant vertex data stored in the mesh.
Definition: TexturedQuad.hpp:50
static constexpr MeshBufferUsage INSTANCES_USAGE
Hint regarding the intended memory access pattern of the instance buffer.
Definition: TexturedQuad.hpp:44