Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
Types.h
Go to the documentation of this file.
1#ifndef ENGINE_SOURCE_TYPES_H_
2#define ENGINE_SOURCE_TYPES_H_
3
4/** @file Types.h
5 * @ingroup mnd_types
6 * @brief Engine-wide primitive type aliases and GLM math imports.
7 *
8 * Every engine subsystem uses these aliases instead of raw stdint or GLM types.
9 * Keeping all aliases here means a single include gives consistent sizing and
10 * naming across the entire codebase (both the Engine library and game code).
11 *
12 * Math types (vec3, mat4, quat …) are thin aliases over GLM and can be passed
13 * directly to any OpenGL uniform upload helper in ShaderProgram.
14 */
15
16#include <cstddef>
17#include <cstdint>
18#include <string>
19
20#include <glm/gtc/quaternion.hpp>
21#include <glm/gtc/type_ptr.hpp>
22
23namespace mnd
24{
25
26/// @defgroup Types Primitive Type Aliases
27/// @brief Sized integer, float, and math type aliases used everywhere in the engine.
28/// @{
29
30using u8 = uint8_t; ///< Unsigned 8-bit integer.
31using u16 = uint16_t; ///< Unsigned 16-bit integer.
32using u32 = uint32_t; ///< Unsigned 32-bit integer — also the GL index type.
33using u64 = uint64_t; ///< Unsigned 64-bit integer.
34
35using i8 = int8_t; ///< Signed 8-bit integer.
36using i16 = int16_t; ///< Signed 16-bit integer.
37using i32 = int32_t; ///< Signed 32-bit integer — used for GL enums and sizes.
38using i64 = int64_t; ///< Signed 64-bit integer.
39
40using f32 = float; ///< 32-bit IEEE float — the standard GL scalar type.
41using f64 = double; ///< 64-bit double — used for high-precision timing.
42
43using usize = size_t; ///< Platform-native unsigned size type.
44
45using str = std::string; ///< Convenience alias for std::string.
46
47/// @defgroup MathTypes GLM Math Type Aliases
48/// @brief Floating-point vector, matrix, and quaternion types backed by GLM.
49/// @{
50using vec2 = glm::vec2; ///< 2-component float vector (e.g. UV coordinates, mouse position).
51using vec3 = glm::vec3; ///< 3-component float vector (e.g. world position, RGB colour, normals).
52using vec4 = glm::vec4; ///< 4-component float vector (e.g. RGBA colour, homogeneous coords).
53
54using ivec2 = glm::ivec2; ///< 2-component signed integer vector.
55using ivec3 = glm::ivec3; ///< 3-component signed integer vector.
56using ivec4 = glm::ivec4; ///< 4-component signed integer vector.
57
58using uvec2 = glm::uvec2; ///< 2-component unsigned integer vector.
59using uvec3 = glm::uvec3; ///< 3-component unsigned integer vector.
60using uvec4 = glm::uvec4; ///< 4-component unsigned integer vector.
61
62using mat3 = glm::mat3; ///< 3×3 column-major float matrix (e.g. normal matrix).
63using mat4 = glm::mat4; ///< 4×4 column-major float matrix (model/view/projection).
64
65using quat = glm::quat; ///< Unit quaternion for rotation (avoids gimbal lock).
66/// @}
67
68/// @brief Bring frequently used GLM free functions into the ENG namespace.
69using glm::angleAxis;
70using glm::cross;
71using glm::degrees;
72using glm::distance;
73using glm::dot;
74using glm::inverse;
75using glm::length;
76using glm::lookAt;
77using glm::mat4_cast;
78using glm::normalize;
79using glm::ortho;
80using glm::perspective;
81using glm::quat_cast;
82using glm::radians;
83using glm::rotate;
84using glm::scale;
85using glm::translate;
86using glm::transpose;
87using glm::value_ptr;
88
89/// @}
90
91} // namespace mnd
92
93#endif // ENGINE_SOURCE_TYPES_H_
glm::vec2 vec2
2-component float vector (e.g. UV coordinates, mouse position).
Definition Types.h:50
glm::mat3 mat3
3×3 column-major float matrix (e.g. normal matrix).
Definition Types.h:62
glm::ivec3 ivec3
3-component signed integer vector.
Definition Types.h:55
glm::mat4 mat4
4×4 column-major float matrix (model/view/projection).
Definition Types.h:63
glm::vec4 vec4
4-component float vector (e.g. RGBA colour, homogeneous coords).
Definition Types.h:52
glm::ivec2 ivec2
2-component signed integer vector.
Definition Types.h:54
glm::uvec3 uvec3
3-component unsigned integer vector.
Definition Types.h:59
glm::vec3 vec3
3-component float vector (e.g. world position, RGB colour, normals).
Definition Types.h:51
glm::quat quat
Unit quaternion for rotation (avoids gimbal lock).
Definition Types.h:65
glm::uvec4 uvec4
4-component unsigned integer vector.
Definition Types.h:60
glm::uvec2 uvec2
2-component unsigned integer vector.
Definition Types.h:58
glm::ivec4 ivec4
4-component signed integer vector.
Definition Types.h:56
std::string str
Convenience alias for std::string.
Definition Types.h:45
double f64
64-bit double — used for high-precision timing.
Definition Types.h:41
uint16_t u16
Unsigned 16-bit integer.
Definition Types.h:31
int64_t i64
Signed 64-bit integer.
Definition Types.h:38
int8_t i8
Signed 8-bit integer.
Definition Types.h:35
float f32
32-bit IEEE float — the standard GL scalar type.
Definition Types.h:40
int32_t i32
Signed 32-bit integer — used for GL enums and sizes.
Definition Types.h:37
uint32_t u32
Unsigned 32-bit integer — also the GL index type.
Definition Types.h:32
int16_t i16
Signed 16-bit integer.
Definition Types.h:36
uint64_t u64
Unsigned 64-bit integer.
Definition Types.h:33
size_t usize
Platform-native unsigned size type.
Definition Types.h:43
uint8_t u8
Unsigned 8-bit integer.
Definition Types.h:30