| 0.9.9 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<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
148 # if (GLM_ARCH & GLM_ARCH_AVX_BIT)
149 template<>
150 struct storage<4, double, true>
151 {
152 typedef glm_f64vec4 type;
153 };
154 # endif
155
156 # if (GLM_ARCH & GLM_ARCH_AVX2_BIT)
157 template<>
158 struct storage<4, detail::int64, true>
159 {
160 typedef glm_i64vec4 type;
161 };
162
163 template<>
164 struct storage<4, detail::uint64, true>
165 {
166 typedef glm_u64vec4 type;
167 };
168 # endif
169
170 enum genTypeEnum
171 {
172 GENTYPE_VEC,
173 GENTYPE_MAT,
174 GENTYPE_QUAT
175 };
176
177 template <typename genType>
178 struct genTypeTrait
179 {};
180
181 template <length_t C, length_t R, typename T>
182 struct genTypeTrait<mat<C, R, T> >
183 {
184 static const genTypeEnum GENTYPE = GENTYPE_MAT;
185 };
186
187 template<typename genType, genTypeEnum type>
188 struct init_gentype
189 {
190 };
191
192 template<typename genType>
193 struct init_gentype<genType, GENTYPE_QUAT>
194 {
195 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity()
196 {
197 return genType(1, 0, 0, 0);
198 }
199 };
200
201 template<typename genType>
202 struct init_gentype<genType, GENTYPE_MAT>
203 {
204 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity()
205 {
206 return genType(1);
207 }
208 };
209 }//namespace detail
210 }//namespace glm
glm::identity
GLM_FUNC_DECL GLM_CONSTEXPR genType identity()
Builds an identity matrix.
glm::uint64
detail::uint64 uint64
64 bit unsigned integer type.
Definition: scalar_uint_sized.hpp:67
glm::int64
detail::int64 int64
64 bit signed integer type.
Definition: scalar_int_sized.hpp:67
glm
Definition: common.hpp:20