Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
vertex_declarations.hpp
Go to the documentation of this file.
1// This file is part of the Rendering Engine project.
2// Author: Alexander Obzherin <alexanderobzherin@gmail.com>
3// Copyright (c) 2025 Alexander Obzherin
4// Distributed under the terms of the zlib License. See LICENSE.md for details.
5
6#pragma once
7
8#include <vector>
9#include <array>
10
11#define GLM_FORCE_RADIANS
12#define GLM_FORCE_DEPTH_ZERO_TO_ONE
13#include <glm/vec2.hpp>
14#include <glm/vec3.hpp>
15#include <glm/vec4.hpp>
16#include <glm/mat4x4.hpp>
17
18namespace rendering_engine
19{
20/**
21 * @brief Contains model, view, and projection matrices for 3D rendering.
22 */
24{
25 glm::mat4 model; ///< Model transformation matrix
26 glm::mat4 view; ///< View (camera) transformation matrix
27 glm::mat4 proj; ///< Projection transformation matrix
28};
29
30/**
31 * @brief Contains transformation matrices for 2D rendering.
32 */
34{
35 glm::mat4 model; ///< Model transformation matrix
36 glm::mat4 view; ///< View (camera) transformation matrix
37 glm::mat4 proj; ///< Projection transformation matrix
38};
39
40/**
41 * @brief Vertex format for 2D UI/Overlay elements.
42 *
43 * Used for sprites, UI widgets, etc.
44 */
46{
47 glm::vec2 position; ///< 2D position in screen or world space
48 glm::vec4 color; ///< Vertex color (RGBA)
49 glm::vec2 textureCoordinates; ///< UV coordinates for texturing
50
51 /// Default constructor.
52 Vertex2D() = default;
53
54 /**
55 * @brief Construct with position, color, and texture coordinates.
56 * @param pos 2D position
57 * @param col RGBA color
58 * @param uv Texture coordinates
59 */
60 Vertex2D(const glm::vec2& pos,
61 const glm::vec4& col,
62 const glm::vec2& uv)
63 :
64 position(pos),
65 color(col),
67 {}
68};
69
70/**
71 * @brief Vertex format for unlit 3D geometry.
72 *
73 * Used for 3D models/materials that don't require lighting calculations,
74 * such as particle systems, billboards, or flat-shaded meshes.
75 */
77 {
78 glm::vec3 position; ///< 3D position
79 glm::vec4 color; ///< Vertex color (RGBA)
80 glm::vec2 textureCoordinates; ///< UV coordinates for texturing
81
83
84 /**
85 * @brief Construct with position, UV, and color.
86 * @param pos 3D position
87 * @param col RGBA color
88 * @param uv Texture coordinates
89 */
90 VertexPositionColorTexture(const glm::vec3& pos,
91 const glm::vec4& col,
92 const glm::vec2& uv
93 )
94 :
95 position(pos),
96 color(col),
98 {}
99 };
100
101/**
102 * @brief Vertex format for lit 3D geometry (normal and tangent support).
103 *
104 * Used for 3D meshes with normal mapping or lighting (Phong, Blinn-Phong, PBR, etc.).
105 */
107{
108 glm::vec3 position; ///< 3D position
109 glm::vec4 color; ///< Vertex color (RGBA)
110 glm::vec2 textureCoordinates; ///< UV coordinates for texturing
111 glm::vec3 normal; ///< Surface normal (for lighting)
112 glm::vec3 tangent; ///< Tangent (for normal mapping)
113
115
116 /**
117 * @brief Construct with all vertex attributes.
118 * @param pos 3D position
119 * @param col RGBA color
120 * @param uv Texture coordinates
121 * @param nrm Normal vector
122 * @param tan Tangent vector
123 */
125 const glm::vec4& col,
126 const glm::vec2& uv,
127 const glm::vec3& nrm,
128 const glm::vec3& tan)
129 :
130 position(pos),
131 color(col),
133 normal(nrm),
134 tangent(tan)
135 {}
136};
137
138/**
139 * @brief Vertex format for skinned meshes (skeletal animation).
140 *
141 * Supports up to 4 bones per vertex. Used for character models and animated geometry.
142 */
144{
145 glm::vec3 position; ///< 3D position
146 glm::vec2 textureCoordinates; ///< UV coordinates for texturing
147 glm::vec3 normal; ///< Surface normal (for lighting)
148 glm::vec3 tangent; ///< Tangent (for normal mapping)
149 glm::uvec4 boneIndices; ///< Indices of influencing bones (up to 4)
150 glm::vec4 boneWeights; ///< Blend weights for each bone (should sum to 1.0)
151
153
154 /**
155 * @brief Construct with all vertex attributes and bone data.
156 * @param pos 3D position
157 * @param uv Texture coordinates
158 * @param nrm Normal vector
159 * @param tan Tangent vector
160 * @param indices Indices of influencing bones
161 * @param weights Blend weights for each bone
162 */
164 const glm::vec2& uv,
165 const glm::vec3& nrm,
166 const glm::vec3& tan,
167 const glm::uvec4& indices,
168 const glm::vec4& weights)
169 :
170 position(pos),
172 normal(nrm),
173 tangent(tan),
174 boneIndices(indices),
175 boneWeights(weights)
176 {}
177};
178
179
180}
Contains transformation matrices for 2D rendering.
glm::mat4 view
View (camera) transformation matrix.
glm::mat4 proj
Projection transformation matrix.
glm::mat4 model
Model transformation matrix.
Contains model, view, and projection matrices for 3D rendering.
glm::mat4 proj
Projection transformation matrix.
glm::mat4 model
Model transformation matrix.
glm::mat4 view
View (camera) transformation matrix.
Vertex2D()=default
Default constructor.
Vertex2D(const glm::vec2 &pos, const glm::vec4 &col, const glm::vec2 &uv)
Construct with position, color, and texture coordinates.
glm::vec4 color
Vertex color (RGBA)
glm::vec2 position
2D position in screen or world space
glm::vec2 textureCoordinates
UV coordinates for texturing.
VertexPositionColorTexture(const glm::vec3 &pos, const glm::vec4 &col, const glm::vec2 &uv)
Construct with position, UV, and color.
glm::vec2 textureCoordinates
UV coordinates for texturing.
VertexPositionColorTextureNormalTangent(const glm::vec3 &pos, const glm::vec4 &col, const glm::vec2 &uv, const glm::vec3 &nrm, const glm::vec3 &tan)
Construct with all vertex attributes.
glm::uvec4 boneIndices
Indices of influencing bones (up to 4)
VertexSkinnedPositionTextureNormalTangent(const glm::vec3 &pos, const glm::vec2 &uv, const glm::vec3 &nrm, const glm::vec3 &tan, const glm::uvec4 &indices, const glm::vec4 &weights)
Construct with all vertex attributes and bone data.
glm::vec4 boneWeights
Blend weights for each bone (should sum to 1.0)