1.0.0 API documentation
Loading...
Searching...
No Matches
qualifier.hpp
1#pragma once
2
3#include "setup.hpp"
4
5namespace glm
6{
8 enum qualifier
9 {
10 packed_highp,
11 packed_mediump,
12 packed_lowp,
13
14# if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE
15 aligned_highp,
16 aligned_mediump,
17 aligned_lowp, // ///< Typed data is aligned in memory allowing SIMD optimizations and operations are executed with high precision in term of ULPs to maximize performance
18 aligned = aligned_highp,
19# endif
20
21 highp = packed_highp,
22 mediump = packed_mediump,
23 lowp = packed_lowp,
24 packed = packed_highp,
25
26# if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE && defined(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES)
27 defaultp = aligned_highp
28# else
29 defaultp = highp
30# endif
31 };
32
33 typedef qualifier precision;
34
35 template<length_t L, typename T, qualifier Q = defaultp> struct vec;
36 template<length_t C, length_t R, typename T, qualifier Q = defaultp> struct mat;
37 template<typename T, qualifier Q = defaultp> struct qua;
38
39# if GLM_HAS_TEMPLATE_ALIASES
40 template <typename T, qualifier Q = defaultp> using tvec1 = vec<1, T, Q>;
41 template <typename T, qualifier Q = defaultp> using tvec2 = vec<2, T, Q>;
42 template <typename T, qualifier Q = defaultp> using tvec3 = vec<3, T, Q>;
43 template <typename T, qualifier Q = defaultp> using tvec4 = vec<4, T, Q>;
44 template <typename T, qualifier Q = defaultp> using tmat2x2 = mat<2, 2, T, Q>;
45 template <typename T, qualifier Q = defaultp> using tmat2x3 = mat<2, 3, T, Q>;
46 template <typename T, qualifier Q = defaultp> using tmat2x4 = mat<2, 4, T, Q>;
47 template <typename T, qualifier Q = defaultp> using tmat3x2 = mat<3, 2, T, Q>;
48 template <typename T, qualifier Q = defaultp> using tmat3x3 = mat<3, 3, T, Q>;
49 template <typename T, qualifier Q = defaultp> using tmat3x4 = mat<3, 4, T, Q>;
50 template <typename T, qualifier Q = defaultp> using tmat4x2 = mat<4, 2, T, Q>;
51 template <typename T, qualifier Q = defaultp> using tmat4x3 = mat<4, 3, T, Q>;
52 template <typename T, qualifier Q = defaultp> using tmat4x4 = mat<4, 4, T, Q>;
53 template <typename T, qualifier Q = defaultp> using tquat = qua<T, Q>;
54# endif
55
56namespace detail
57{
58 template<glm::qualifier P>
59 struct is_aligned
60 {
61 static const bool value = false;
62 };
63
64# if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE
65 template<>
66 struct is_aligned<glm::aligned_lowp>
67 {
68 static const bool value = true;
69 };
70
71 template<>
72 struct is_aligned<glm::aligned_mediump>
73 {
74 static const bool value = true;
75 };
76
77 template<>
78 struct is_aligned<glm::aligned_highp>
79 {
80 static const bool value = true;
81 };
82# endif
83
84 template<length_t L, typename T, bool is_aligned>
85 struct storage
86 {
87 typedef struct type {
88 T data[L];
89 } type;
90 };
91
92# if GLM_HAS_ALIGNOF
93 template<length_t L, typename T>
94 struct storage<L, T, true>
95 {
96 typedef struct alignas(L * sizeof(T)) type {
97 T data[L];
98 } type;
99 };
100
101 template<typename T>
102 struct storage<3, T, true>
103 {
104 typedef struct alignas(4 * sizeof(T)) type {
105 T data[4];
106 } type;
107 };
108# endif
109
110# if GLM_ARCH & GLM_ARCH_SSE2_BIT
111 template<>
112 struct storage<4, float, true>
113 {
114 typedef glm_f32vec4 type;
115 };
116
117 template<>
118 struct storage<4, int, true>
119 {
120 typedef glm_i32vec4 type;
121 };
122
123 template<>
124 struct storage<4, unsigned int, true>
125 {
126 typedef glm_u32vec4 type;
127 };
128
129 template<>
130 struct storage<2, double, true>
131 {
132 typedef glm_f64vec2 type;
133 };
134
135 template<>
136 struct storage<2, detail::int64, true>
137 {
138 typedef glm_i64vec2 type;
139 };
140
141 template<>
142 struct storage<2, detail::uint64, true>
143 {
144 typedef glm_u64vec2 type;
145 };
146# endif
147# if (GLM_ARCH & GLM_ARCH_AVX_BIT)
148 template<>
149 struct storage<4, double, true>
150 {
151 typedef glm_f64vec4 type;
152 };
153# endif
154
155# if (GLM_ARCH & GLM_ARCH_AVX2_BIT)
156 template<>
157 struct storage<4, detail::int64, true>
158 {
159 typedef glm_i64vec4 type;
160 };
161
162 template<>
163 struct storage<4, detail::uint64, true>
164 {
165 typedef glm_u64vec4 type;
166 };
167# endif
168
169# if GLM_ARCH & GLM_ARCH_NEON_BIT
170 template<>
171 struct storage<4, float, true>
172 {
173 typedef glm_f32vec4 type;
174 };
175
176 template<>
177 struct storage<4, int, true>
178 {
179 typedef glm_i32vec4 type;
180 };
181
182 template<>
183 struct storage<4, unsigned int, true>
184 {
185 typedef glm_u32vec4 type;
186 };
187# endif
188
189 enum genTypeEnum
190 {
191 GENTYPE_VEC,
192 GENTYPE_MAT,
193 GENTYPE_QUAT
194 };
195
196 template <typename genType>
197 struct genTypeTrait
198 {};
199
200 template <length_t C, length_t R, typename T>
201 struct genTypeTrait<mat<C, R, T> >
202 {
203 static const genTypeEnum GENTYPE = GENTYPE_MAT;
204 };
205
206 template<typename genType, genTypeEnum type>
207 struct init_gentype
208 {
209 };
210
211 template<typename genType>
212 struct init_gentype<genType, GENTYPE_QUAT>
213 {
214 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity()
215 {
216 return genType(1, 0, 0, 0);
217 }
218 };
219
220 template<typename genType>
221 struct init_gentype<genType, GENTYPE_MAT>
222 {
223 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity()
224 {
225 return genType(1);
226 }
227 };
228}//namespace detail
229}//namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR genType identity()
Builds an identity matrix.