1.0.2 API documentation
qualifier.hpp
1 #pragma once
2 
3 #include "setup.hpp"
4 
5 namespace 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 
56 namespace 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<3, float, true>
131  {
132  typedef glm_f32vec4 type;
133  };
134 
135  template<>
136  struct storage<3, int, true>
137  {
138  typedef glm_i32vec4 type;
139  };
140 
141  template<>
142  struct storage<3, unsigned int, true>
143  {
144  typedef glm_u32vec4 type;
145  };
146 
147  template<>
148  struct storage<2, double, true>
149  {
150  typedef glm_f64vec2 type;
151  };
152 
153  template<>
154  struct storage<2, detail::int64, true>
155  {
156  typedef glm_i64vec2 type;
157  };
158 
159  template<>
160  struct storage<2, detail::uint64, true>
161  {
162  typedef glm_u64vec2 type;
163  };
164 
165 
166  template<>
167  struct storage<3, detail::uint64, true>
168  {
169  typedef glm_u64vec2 type;
170  };
171 
172  template<>
173  struct storage<4, double, true>
174  {
175 # if (GLM_ARCH & GLM_ARCH_AVX_BIT)
176  typedef glm_f64vec4 type;
177 # else
178  struct type
179  {
180  glm_f64vec2 data[2];
181  GLM_CONSTEXPR glm_f64vec2 getv(int i) const {
182  return data[i];
183  }
184  GLM_CONSTEXPR void setv(int i, const glm_f64vec2& v) {
185  data[i] = v;
186  }
187  };
188 # endif
189  };
190 
191 
192  template<>
193  struct storage<3, double, true> : public storage<4, double, true>
194  {};
195 
196 # endif
197 
198 # if (GLM_ARCH & GLM_ARCH_AVX2_BIT)
199  template<>
200  struct storage<4, detail::int64, true>
201  {
202  typedef glm_i64vec4 type;
203  };
204 
205  template<>
206  struct storage<4, detail::uint64, true>
207  {
208  typedef glm_u64vec4 type;
209  };
210 # endif
211 
212 # if GLM_ARCH & GLM_ARCH_NEON_BIT
213  template<>
214  struct storage<4, float, true>
215  {
216  typedef glm_f32vec4 type;
217  };
218 
219  template<>
220  struct storage<3, float, true> : public storage<4, float, true>
221  {};
222 
223  template<>
224  struct storage<4, int, true>
225  {
226  typedef glm_i32vec4 type;
227  };
228 
229  template<>
230  struct storage<3, int, true> : public storage<4, int, true>
231  {};
232 
233  template<>
234  struct storage<4, unsigned int, true>
235  {
236  typedef glm_u32vec4 type;
237  };
238 
239  template<>
240  struct storage<3, unsigned int, true> : public storage<4, unsigned int, true>
241  {};
242 
243 # if GLM_HAS_ALIGNOF
244  template<>
245  struct storage<3, double, true>
246  {
247  typedef struct alignas(4 * sizeof(double)) type {
248  double data[4];
249  } type;
250  };
251 # endif//GLM_HAS_ALIGNOF
252 
253 # endif
254 
255  enum genTypeEnum
256  {
257  GENTYPE_VEC,
258  GENTYPE_MAT,
259  GENTYPE_QUAT
260  };
261 
262  template <typename genType>
263  struct genTypeTrait
264  {};
265 
266  template <length_t C, length_t R, typename T>
267  struct genTypeTrait<mat<C, R, T> >
268  {
269  static const genTypeEnum GENTYPE = GENTYPE_MAT;
270  };
271 
272  template<typename genType, genTypeEnum type>
273  struct init_gentype
274  {
275  };
276 
277  template<typename genType>
278  struct init_gentype<genType, GENTYPE_QUAT>
279  {
280  GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity()
281  {
282  return genType(1, 0, 0, 0);
283  }
284  };
285 
286  template<typename genType>
287  struct init_gentype<genType, GENTYPE_MAT>
288  {
289  GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity()
290  {
291  return genType(1);
292  }
293  };
294 }//namespace detail
295 }//namespace glm
glm::uint64
detail::uint64 uint64
64 bit unsigned integer type.
Definition: scalar_uint_sized.hpp:67
glm::identity
GLM_FUNC_DECL GLM_CONSTEXPR genType identity()
Builds an identity matrix.
glm::int64
detail::int64 int64
64 bit signed integer type.
Definition: scalar_int_sized.hpp:67