0.9.9 API documenation

- Main Page
- Modules
- Files

- File List

setup.hpp
Go to the documentation of this file.
1
4 #ifndef GLM_SETUP_INCLUDED
5
6 #define GLM_VERSION_MAJOR 0
7 #define GLM_VERSION_MINOR 9
8 #define GLM_VERSION_PATCH 9
9 #define GLM_VERSION_REVISION 0
10 #define GLM_VERSION 990
11
12 #define GLM_SETUP_INCLUDED GLM_VERSION
13
14 #if defined(GLM_FORCE_SWIZZLE) && defined(GLM_FORCE_UNRESTRICTED_GENTYPE)
15 # error "Both GLM_FORCE_SWIZZLE and GLM_FORCE_UNRESTRICTED_GENTYPE can't be defined at the same time"
16 #endif
17
18 #include <cassert>
19 #include <cstddef>
20
22 // Messages
23
24 #define GLM_MESSAGES_ENABLED 1
25 #define GLM_MESSAGES_DISABLE 0
26
27 #if defined(GLM_FORCE_MESSAGES)
28 # define GLM_MESSAGES GLM_MESSAGES_ENABLED
29 #else
30 # define GLM_MESSAGES GLM_MESSAGES_DISABLE
31 #endif
32
34 // Detect the platform
35
36 #include "../simd/platform.h"
37
39 // Version
40
41 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_VERSION_DISPLAYED)
42 # define GLM_MESSAGE_VERSION_DISPLAYED
43 # pragma message ("GLM: version 0.9.9.0")
44 #endif//GLM_MESSAGES
45
46 // Report compiler detection
47 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_COMPILER_DISPLAYED)
48 # define GLM_MESSAGE_COMPILER_DISPLAYED
49 # if GLM_COMPILER & GLM_COMPILER_CUDA
50 # pragma message("GLM: CUDA compiler detected")
51 # elif GLM_COMPILER & GLM_COMPILER_VC
52 # pragma message("GLM: Visual C++ compiler detected")
53 # elif GLM_COMPILER & GLM_COMPILER_CLANG
54 # pragma message("GLM: Clang compiler detected")
55 # elif GLM_COMPILER & GLM_COMPILER_INTEL
56 # pragma message("GLM: Intel Compiler detected")
57 # elif GLM_COMPILER & GLM_COMPILER_GCC
58 # pragma message("GLM: GCC compiler detected")
59 # else
60 # pragma message("GLM: Compiler not detected")
61 # endif
62 #endif//GLM_MESSAGES
63
65 // Build model
66
67 #if defined(__arch64__) || defined(__LP64__) || defined(_M_X64) || defined(__ppc64__) || defined(__x86_64__)
68 # define GLM_MODEL GLM_MODEL_64
69 #elif defined(__i386__) || defined(__ppc__)
70 # define GLM_MODEL GLM_MODEL_32
71 #else
72 # define GLM_MODEL GLM_MODEL_32
73 #endif//
74
75 #if !defined(GLM_MODEL) && GLM_COMPILER != 0
76 # error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
77 #endif//GLM_MODEL
78
79 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_MODEL_DISPLAYED)
80 # define GLM_MESSAGE_MODEL_DISPLAYED
81 # if(GLM_MODEL == GLM_MODEL_64)
82 # pragma message("GLM: 64 bits model")
83 # elif(GLM_MODEL == GLM_MODEL_32)
84 # pragma message("GLM: 32 bits model")
85 # endif//GLM_MODEL
86 #endif//GLM_MESSAGES
87
88 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_ARCH_DISPLAYED)
89 # define GLM_MESSAGE_ARCH_DISPLAYED
90 # if(GLM_ARCH == GLM_ARCH_PURE)
91 # pragma message("GLM: Platform independent code")
92 # elif(GLM_ARCH == GLM_ARCH_AVX2)
93 # pragma message("GLM: AVX2 instruction set")
94 # elif(GLM_ARCH == GLM_ARCH_AVX)
95 # pragma message("GLM: AVX instruction set")
96 # elif(GLM_ARCH == GLM_ARCH_SSE42)
97 # pragma message("GLM: SSE4.2 instruction set")
98 # elif(GLM_ARCH == GLM_ARCH_SSE41)
99 # pragma message("GLM: SSE4.1 instruction set")
100 # elif(GLM_ARCH == GLM_ARCH_SSSE3)
101 # pragma message("GLM: SSSE3 instruction set")
102 # elif(GLM_ARCH == GLM_ARCH_SSE3)
103 # pragma message("GLM: SSE3 instruction set")
104 # elif(GLM_ARCH == GLM_ARCH_SSE2)
105 # pragma message("GLM: SSE2 instruction set")
106 # elif(GLM_ARCH == GLM_ARCH_X86)
107 # pragma message("GLM: x86 instruction set")
108 # elif(GLM_ARCH == GLM_ARCH_NEON)
109 # pragma message("GLM: NEON instruction set")
110 # elif(GLM_ARCH == GLM_ARCH_ARM)
111 # pragma message("GLM: ARM instruction set")
112 # elif(GLM_ARCH == GLM_ARCH_MIPS)
113 # pragma message("GLM: MIPS instruction set")
114 # elif(GLM_ARCH == GLM_ARCH_PPC)
115 # pragma message("GLM: PowerPC architechture")
116 # endif//GLM_ARCH
117 #endif//GLM_MESSAGES
118
120 // C++ Version
121
122 // User defines: GLM_FORCE_CXX98, GLM_FORCE_CXX03, GLM_FORCE_CXX11, GLM_FORCE_CXX14
123
124 #define GLM_LANG_CXX98_FLAG (1 << 1)
125 #define GLM_LANG_CXX03_FLAG (1 << 2)
126 #define GLM_LANG_CXX0X_FLAG (1 << 3)
127 #define GLM_LANG_CXX11_FLAG (1 << 4)
128 #define GLM_LANG_CXX1Y_FLAG (1 << 5)
129 #define GLM_LANG_CXX14_FLAG (1 << 6)
130 #define GLM_LANG_CXX1Z_FLAG (1 << 7)
131 #define GLM_LANG_CXXMS_FLAG (1 << 8)
132 #define GLM_LANG_CXXGNU_FLAG (1 << 9)
133
134 #define GLM_LANG_CXX98 GLM_LANG_CXX98_FLAG
135 #define GLM_LANG_CXX03 (GLM_LANG_CXX98 | GLM_LANG_CXX03_FLAG)
136 #define GLM_LANG_CXX0X (GLM_LANG_CXX03 | GLM_LANG_CXX0X_FLAG)
137 #define GLM_LANG_CXX11 (GLM_LANG_CXX0X | GLM_LANG_CXX11_FLAG)
138 #define GLM_LANG_CXX1Y (GLM_LANG_CXX11 | GLM_LANG_CXX1Y_FLAG)
139 #define GLM_LANG_CXX14 (GLM_LANG_CXX1Y | GLM_LANG_CXX14_FLAG)
140 #define GLM_LANG_CXX1Z (GLM_LANG_CXX14 | GLM_LANG_CXX1Z_FLAG)
141 #define GLM_LANG_CXXMS GLM_LANG_CXXMS_FLAG
142 #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG
143
144 #if defined(GLM_FORCE_CXX14)
145 # if((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER <= GLM_COMPILER_GCC50)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER <= GLM_COMPILER_CLANG34))
146 # pragma message("GLM: Using GLM_FORCE_CXX14 with a compiler that doesn't fully support C++14")
147 # elif GLM_COMPILER & GLM_COMPILER_VC
148 # pragma message("GLM: Using GLM_FORCE_CXX14 but there is no known version of Visual C++ compiler that fully supports C++14")
149 # elif GLM_COMPILER & GLM_COMPILER_INTEL
150 # pragma message("GLM: Using GLM_FORCE_CXX14 but there is no known version of ICC compiler that fully supports C++14")
151 # endif
152 # define GLM_LANG GLM_LANG_CXX14
153 # define GLM_LANG_STL11_FORCED
154 #elif defined(GLM_FORCE_CXX11)
155 # if((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER <= GLM_COMPILER_GCC48)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER <= GLM_COMPILER_CLANG33))
156 # pragma message("GLM: Using GLM_FORCE_CXX11 with a compiler that doesn't fully support C++11")
157 # elif GLM_COMPILER & GLM_COMPILER_VC
158 # pragma message("GLM: Using GLM_FORCE_CXX11 but there is no known version of Visual C++ compiler that fully supports C++11")
159 # elif GLM_COMPILER & GLM_COMPILER_INTEL
160 # pragma message("GLM: Using GLM_FORCE_CXX11 but there is no known version of ICC compiler that fully supports C++11")
161 # endif
162 # define GLM_LANG GLM_LANG_CXX11
163 # define GLM_LANG_STL11_FORCED
164 #elif defined(GLM_FORCE_CXX03)
165 # define GLM_LANG GLM_LANG_CXX03
166 #elif defined(GLM_FORCE_CXX98)
167 # define GLM_LANG GLM_LANG_CXX98
168 #else
169 # if GLM_COMPILER & GLM_COMPILER_CLANG
170 # if __cplusplus >= 201402L // GLM_COMPILER_CLANG34 + -std=c++14
171 # define GLM_LANG GLM_LANG_CXX14
172 # elif __has_feature(cxx_decltype_auto) && __has_feature(cxx_aggregate_nsdmi) // GLM_COMPILER_CLANG33 + -std=c++1y
173 # define GLM_LANG GLM_LANG_CXX1Y
174 # elif __cplusplus >= 201103L // GLM_COMPILER_CLANG33 + -std=c++11
175 # define GLM_LANG GLM_LANG_CXX11
176 # elif __has_feature(cxx_static_assert) // GLM_COMPILER_CLANG29 + -std=c++11
177 # define GLM_LANG GLM_LANG_CXX0X
178 # elif __cplusplus >= 199711L
179 # define GLM_LANG GLM_LANG_CXX98
180 # else
181 # define GLM_LANG GLM_LANG_CXX
182 # endif
183 # elif GLM_COMPILER & GLM_COMPILER_GCC
184 # if __cplusplus >= 201402L
185 # define GLM_LANG GLM_LANG_CXX14
186 # elif __cplusplus >= 201103L
187 # define GLM_LANG GLM_LANG_CXX11
188 # elif defined(__GXX_EXPERIMENTAL_CXX0X__)
189 # define GLM_LANG GLM_LANG_CXX0X
190 # else
191 # define GLM_LANG GLM_LANG_CXX98
192 # endif
193 # elif GLM_COMPILER & GLM_COMPILER_VC
194 # ifdef _MSC_EXTENSIONS
195 # if __cplusplus >= 201402L
196 # define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_CXXMS_FLAG)
197 # elif __cplusplus >= 201103L
198 # define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_CXXMS_FLAG)
199 # else
200 # define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
201 # endif
202 # else
203 # if __cplusplus >= 201402L
204 # define GLM_LANG GLM_LANG_CXX14
205 # elif __cplusplus >= 201103L
206 # define GLM_LANG GLM_LANG_CXX11
207 # else
208 # define GLM_LANG GLM_LANG_CXX0X
209 # endif
210 # endif
211 # elif GLM_COMPILER & GLM_COMPILER_INTEL
212 # ifdef _MSC_EXTENSIONS
213 # define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
214 # else
215 # define GLM_MSC_EXT 0
216 # endif
217 # if __cplusplus >= 201402L
218 # define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT)
219 # elif __cplusplus >= 201103L
220 # define GLM_LANG (GLM_LANG_CXX11 | GLM_MSC_EXT)
221 # elif __INTEL_CXX11_MODE__
222 # define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT)
223 # elif __cplusplus >= 199711L
224 # define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT)
225 # else
226 # define GLM_LANG (GLM_LANG_CXX | GLM_MSC_EXT)
227 # endif
228 # elif GLM_COMPILER & GLM_COMPILER_CUDA
229 # ifdef _MSC_EXTENSIONS
230 # define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
231 # else
232 # define GLM_MSC_EXT 0
233 # endif
234 # if GLM_COMPILER >= GLM_COMPILER_CUDA75
235 # define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT)
236 # else
237 # define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT)
238 # endif
239 # else // Unknown compiler
240 # if __cplusplus >= 201402L
241 # define GLM_LANG GLM_LANG_CXX14
242 # elif __cplusplus >= 201103L
243 # define GLM_LANG GLM_LANG_CXX11
244 # elif __cplusplus >= 199711L
245 # define GLM_LANG GLM_LANG_CXX98
246 # else
247 # define GLM_LANG GLM_LANG_CXX // Good luck with that!
248 # endif
249 # ifndef GLM_FORCE_PURE
250 # define GLM_FORCE_PURE
251 # endif
252 # endif
253 #endif
254
255 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_LANG_DISPLAYED)
256 # define GLM_MESSAGE_LANG_DISPLAYED
257
258 # if GLM_LANG & GLM_LANG_CXX1Z_FLAG
259 # pragma message("GLM: C++1z")
260 # elif GLM_LANG & GLM_LANG_CXX14_FLAG
261 # pragma message("GLM: C++14")
262 # elif GLM_LANG & GLM_LANG_CXX1Y_FLAG
263 # pragma message("GLM: C++1y")
264 # elif GLM_LANG & GLM_LANG_CXX11_FLAG
265 # pragma message("GLM: C++11")
266 # elif GLM_LANG & GLM_LANG_CXX0X_FLAG
267 # pragma message("GLM: C++0x")
268 # elif GLM_LANG & GLM_LANG_CXX03_FLAG
269 # pragma message("GLM: C++03")
270 # elif GLM_LANG & GLM_LANG_CXX98_FLAG
271 # pragma message("GLM: C++98")
272 # else
273 # pragma message("GLM: C++ language undetected")
274 # endif//GLM_LANG
275
276 # if GLM_LANG & (GLM_LANG_CXXGNU_FLAG | GLM_LANG_CXXMS_FLAG)
277 # pragma message("GLM: Language extensions enabled")
278 # endif//GLM_LANG
279 #endif//GLM_MESSAGES
280
282 // Has of C++ features
283
284 // http://clang.llvm.org/cxx_status.html
285 // http://gcc.gnu.org/projects/cxx0x.html
286 // http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
287
288 // Android has multiple STLs but C++11 STL detection doesn't always work #284 #564
289 #if GLM_PLATFORM == GLM_PLATFORM_ANDROID && !defined(GLM_LANG_STL11_FORCED)
290 # define GLM_HAS_CXX11_STL 0
291 #elif GLM_COMPILER & GLM_COMPILER_CLANG
292 # if (defined(_LIBCPP_VERSION) && GLM_LANG & GLM_LANG_CXX11_FLAG) || defined(GLM_LANG_STL11_FORCED)
293 # define GLM_HAS_CXX11_STL 1
294 # else
295 # define GLM_HAS_CXX11_STL 0
296 # endif
297 #else
298 # define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
299 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
300 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
301 ((GLM_PLATFORM != GLM_PLATFORM_WINDOWS) && (GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15))))
302 #endif
303
304 // N1720
305 #if GLM_COMPILER & GLM_COMPILER_CLANG
306 # define GLM_HAS_STATIC_ASSERT __has_feature(cxx_static_assert)
307 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
308 # define GLM_HAS_STATIC_ASSERT 1
309 #else
310 # define GLM_HAS_STATIC_ASSERT ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
311 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
312 ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \
313 ((GLM_COMPILER & GLM_COMPILER_VC))))
314 #endif
315
316 // N1988
317 #if GLM_LANG & GLM_LANG_CXX11_FLAG
318 # define GLM_HAS_EXTENDED_INTEGER_TYPE 1
319 #else
320 # define GLM_HAS_EXTENDED_INTEGER_TYPE (\
321 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC)) || \
322 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CUDA)) || \
323 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC)) || \
324 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CLANG)))
325 #endif
326
327 // N2235
328 #if GLM_COMPILER & GLM_COMPILER_CLANG
329 # define GLM_HAS_CONSTEXPR __has_feature(cxx_constexpr)
330 # define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR
331 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
332 # define GLM_HAS_CONSTEXPR 1
333 # define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR
334 #else
335 # define GLM_HAS_CONSTEXPR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
336 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)) || \
337 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)))) // GCC 4.6 support constexpr but there is a compiler bug causing a crash
338 # define GLM_HAS_CONSTEXPR_PARTIAL (GLM_HAS_CONSTEXPR || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)))
339 #endif
340
341 // N2672
342 #if GLM_COMPILER & GLM_COMPILER_CLANG
343 # define GLM_HAS_INITIALIZER_LISTS __has_feature(cxx_generalized_initializers)
344 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
345 # define GLM_HAS_INITIALIZER_LISTS 1
346 #else
347 # define GLM_HAS_INITIALIZER_LISTS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
348 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
349 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
350 ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA75))))
351 #endif
352
353 // N2544 Unrestricted unions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
354 #if GLM_COMPILER & GLM_COMPILER_CLANG
355 # define GLM_HAS_UNRESTRICTED_UNIONS __has_feature(cxx_unrestricted_unions)
356 #elif GLM_LANG & (GLM_LANG_CXX11_FLAG | GLM_LANG_CXXMS_FLAG)
357 # define GLM_HAS_UNRESTRICTED_UNIONS 1
358 #else
359 # define GLM_HAS_UNRESTRICTED_UNIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
360 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_LANG & GLM_LANG_CXXMS_FLAG)) || \
361 ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA75)) || \
362 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)))
363 #endif
364
365 // N2346
366 #if defined(GLM_FORCE_UNRESTRICTED_GENTYPE)
367 # define GLM_HAS_DEFAULTED_FUNCTIONS 0
368 #elif GLM_COMPILER & GLM_COMPILER_CLANG
369 # define GLM_HAS_DEFAULTED_FUNCTIONS __has_feature(cxx_defaulted_functions)
370 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
371 # define GLM_HAS_DEFAULTED_FUNCTIONS 1
372 #else
373 # define GLM_HAS_DEFAULTED_FUNCTIONS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
374 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
375 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
376 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
377 (GLM_COMPILER & GLM_COMPILER_CUDA)))
378 #endif
379
380 // N2118
381 #if GLM_COMPILER & GLM_COMPILER_CLANG
382 # define GLM_HAS_RVALUE_REFERENCES __has_feature(cxx_rvalue_references)
383 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
384 # define GLM_HAS_RVALUE_REFERENCES 1
385 #else
386 # define GLM_HAS_RVALUE_REFERENCES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
387 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
388 ((GLM_COMPILER & GLM_COMPILER_VC)) || \
389 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
390 #endif
391
392 // N2437 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
393 #if GLM_COMPILER & GLM_COMPILER_CLANG
394 # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS __has_feature(cxx_explicit_conversions)
395 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
396 # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS 1
397 #else
398 # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
399 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
400 ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \
401 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
402 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
403 #endif
404
405 // N2258 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
406 #if GLM_COMPILER & GLM_COMPILER_CLANG
407 # define GLM_HAS_TEMPLATE_ALIASES __has_feature(cxx_alias_templates)
408 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
409 # define GLM_HAS_TEMPLATE_ALIASES 1
410 #else
411 # define GLM_HAS_TEMPLATE_ALIASES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
412 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
413 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \
414 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
415 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
416 #endif
417
418 // N2930 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html
419 #if GLM_COMPILER & GLM_COMPILER_CLANG
420 # define GLM_HAS_RANGE_FOR __has_feature(cxx_range_for)
421 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
422 # define GLM_HAS_RANGE_FOR 1
423 #else
424 # define GLM_HAS_RANGE_FOR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
425 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \
426 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
427 ((GLM_COMPILER & GLM_COMPILER_VC)) || \
428 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
429 #endif
430
431 // N2341 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
432 #if GLM_COMPILER & GLM_COMPILER_CLANG
433 # define GLM_HAS_ALIGNOF __has_feature(c_alignof)
434 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
435 # define GLM_HAS_ALIGNOF 1
436 #else
437 # define GLM_HAS_ALIGNOF ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
438 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
439 ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)) || \
440 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)) || \
441 ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA70))))
442 #endif
443
444 #define GLM_HAS_ONLY_XYZW ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC46))
445 #if GLM_HAS_ONLY_XYZW
446 # pragma message("GLM: GCC older than 4.6 has a bug presenting the use of rgba and stpq components")
447 #endif
448
449 //
450 #if GLM_LANG & GLM_LANG_CXX11_FLAG
451 # define GLM_HAS_ASSIGNABLE 1
452 #else
453 # define GLM_HAS_ASSIGNABLE ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
454 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)) || \
455 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49))))
456 #endif
457
458 //
459 #define GLM_HAS_TRIVIAL_QUERIES 0
460
461 //
462 #if GLM_LANG & GLM_LANG_CXX11_FLAG
463 # define GLM_HAS_MAKE_SIGNED 1
464 #else
465 # define GLM_HAS_MAKE_SIGNED ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
466 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
467 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
468 #endif
469
470 #if GLM_ARCH == GLM_ARCH_PURE
471 # define GLM_HAS_BITSCAN_WINDOWS 0
472 #else
473 # define GLM_HAS_BITSCAN_WINDOWS ((GLM_PLATFORM & GLM_PLATFORM_WINDOWS) && (\
474 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
475 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14) && (GLM_ARCH & GLM_ARCH_X86_BIT))))
476 #endif
477
478 // OpenMP
479 #ifdef _OPENMP
480 # if GLM_COMPILER & GLM_COMPILER_GCC
481 # if GLM_COMPILER >= GLM_COMPILER_GCC61
482 # define GLM_HAS_OPENMP 45
483 # elif GLM_COMPILER >= GLM_COMPILER_GCC49
484 # define GLM_HAS_OPENMP 40
485 # elif GLM_COMPILER >= GLM_COMPILER_GCC47
486 # define GLM_HAS_OPENMP 31
487 # else
488 # define GLM_HAS_OPENMP 0
489 # endif
490 # elif GLM_COMPILER & GLM_COMPILER_CLANG
491 # if GLM_COMPILER >= GLM_COMPILER_CLANG38
492 # define GLM_HAS_OPENMP 31
493 # else
494 # define GLM_HAS_OPENMP 0
495 # endif
496 # elif GLM_COMPILER & GLM_COMPILER_VC
497 # define GLM_HAS_OPENMP 20
498 # elif GLM_COMPILER & GLM_COMPILER_INTEL
499 # if GLM_COMPILER >= GLM_COMPILER_INTEL16
500 # define GLM_HAS_OPENMP 40
501 # else
502 # define GLM_HAS_OPENMP 0
503 # endif
504 # else
505 # define GLM_HAS_OPENMP 0
506 # endif
507 #else
508 # define GLM_HAS_OPENMP 0
509 #endif
510
512 // Static assert
513
514 #if GLM_HAS_STATIC_ASSERT
515 # define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
516 #elif GLM_COMPILER & GLM_COMPILER_VC
517 # define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
518 #else
519 # define GLM_STATIC_ASSERT(x, message)
520 # define GLM_STATIC_ASSERT_NULL
521 #endif//GLM_LANG
522
524 // Qualifiers
525
526 #if GLM_COMPILER & GLM_COMPILER_CUDA
527 # define GLM_CUDA_FUNC_DEF __device__ __host__
528 # define GLM_CUDA_FUNC_DECL __device__ __host__
529 #else
530 # define GLM_CUDA_FUNC_DEF
531 # define GLM_CUDA_FUNC_DECL
532 #endif
533
534 #if GLM_COMPILER & GLM_COMPILER_GCC
535 # define GLM_VAR_USED __attribute__ ((unused))
536 #else
537 # define GLM_VAR_USED
538 #endif
539
540 #if defined(GLM_FORCE_INLINE)
541 # if GLM_COMPILER & GLM_COMPILER_VC
542 # define GLM_INLINE __forceinline
543 # define GLM_NEVER_INLINE __declspec((noinline))
544 # elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)
545 # define GLM_INLINE inline __attribute__((__always_inline__))
546 # define GLM_NEVER_INLINE __attribute__((__noinline__))
547 # elif GLM_COMPILER & GLM_COMPILER_CUDA
548 # define GLM_INLINE __forceinline__
549 # define GLM_NEVER_INLINE __noinline__
550 # else
551 # define GLM_INLINE inline
552 # define GLM_NEVER_INLINE
553 # endif//GLM_COMPILER
554 #else
555 # define GLM_INLINE inline
556 # define GLM_NEVER_INLINE
557 #endif//defined(GLM_FORCE_INLINE)
558
559 #define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL
560 #define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE
561
563 // Swizzle operators
564
565 // User defines: GLM_FORCE_SWIZZLE
566
567 #define GLM_SWIZZLE_ENABLED 1
568 #define GLM_SWIZZLE_DISABLE 0
569
570 #if defined(GLM_FORCE_SWIZZLE)
571 # define GLM_SWIZZLE GLM_SWIZZLE_ENABLED
572 #else
573 # define GLM_SWIZZLE GLM_SWIZZLE_DISABLE
574 #endif
575
576 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)
577 # define GLM_MESSAGE_SWIZZLE_DISPLAYED
578 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
579 # pragma message("GLM: Swizzling operators enabled")
580 # else
581 # pragma message("GLM: Swizzling operators disabled, #define GLM_SWIZZLE to enable swizzle operators")
582 # endif
583 #endif//GLM_MESSAGES
584
586 // Allows using not basic types as genType
587
588 // #define GLM_FORCE_UNRESTRICTED_GENTYPE
589
590 #ifdef GLM_FORCE_UNRESTRICTED_GENTYPE
591 # define GLM_UNRESTRICTED_GENTYPE 1
592 #else
593 # define GLM_UNRESTRICTED_GENTYPE 0
594 #endif
595
596 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED)
597 # define GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED
598 # ifdef GLM_FORCE_UNRESTRICTED_GENTYPE
599 # pragma message("GLM: Use unrestricted genType")
600 # endif
601 #endif//GLM_MESSAGES
602
604 // Clip control
605
606 #define GLM_DEPTH_ZERO_TO_ONE 0x00000001
607 #define GLM_DEPTH_NEGATIVE_ONE_TO_ONE 0x00000002
608
609 #ifdef GLM_FORCE_DEPTH_ZERO_TO_ONE
610 # define GLM_DEPTH_CLIP_SPACE GLM_DEPTH_ZERO_TO_ONE
611 #else
612 # define GLM_DEPTH_CLIP_SPACE GLM_DEPTH_NEGATIVE_ONE_TO_ONE
613 #endif
614
615 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_DEPTH_DISPLAYED)
616 # define GLM_MESSAGE_DEPTH_DISPLAYED
617 # if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE
618 # pragma message("GLM: Depth clip space: Zero to one")
619 # else
620 # pragma message("GLM: Depth clip space: negative one to one")
621 # endif
622 #endif//GLM_MESSAGES
623
625 // Coordinate system, define GLM_FORCE_LEFT_HANDED before including GLM
626 // to use left handed coordinate system by default.
627
628 #define GLM_LEFT_HANDED 0x00000001 // For DirectX, Metal, Vulkan
629 #define GLM_RIGHT_HANDED 0x00000002 // For OpenGL, default in GLM
630
631 #ifdef GLM_FORCE_LEFT_HANDED
632 # define GLM_COORDINATE_SYSTEM GLM_LEFT_HANDED
633 #else
634 # define GLM_COORDINATE_SYSTEM GLM_RIGHT_HANDED
635 #endif
636
637 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_HANDED_DISPLAYED)
638 # define GLM_MESSAGE_HANDED_DISPLAYED
639 # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED
640 # pragma message("GLM: Coordinate system: left handed")
641 # else
642 # pragma message("GLM: Coordinate system: right handed")
643 # endif
644 #endif//GLM_MESSAGES
645
647 // Qualifiers
648
649 #if (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))
650 # define GLM_DEPRECATED __declspec(deprecated)
651 # define GLM_ALIGN(x) __declspec(align(x))
652 # define GLM_ALIGNED_STRUCT(x) struct __declspec(align(x))
653 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef __declspec(align(alignment)) type name
654 # define GLM_RESTRICT_FUNC __declspec(restrict)
655 # define GLM_RESTRICT __restrict
656 # if GLM_COMPILER >= GLM_COMPILER_VC12
657 # define GLM_VECTOR_CALL __vectorcall
658 # else
659 # define GLM_VECTOR_CALL
660 # endif
661 #elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG | GLM_COMPILER_INTEL)
662 # define GLM_DEPRECATED __attribute__((__deprecated__))
663 # define GLM_ALIGN(x) __attribute__((aligned(x)))
664 # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
665 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name __attribute__((aligned(alignment)))
666 # define GLM_RESTRICT_FUNC __restrict__
667 # define GLM_RESTRICT __restrict__
668 # if GLM_COMPILER & GLM_COMPILER_CLANG
669 # if GLM_COMPILER >= GLM_COMPILER_CLANG37
670 # define GLM_VECTOR_CALL __vectorcall
671 # else
672 # define GLM_VECTOR_CALL
673 # endif
674 # else
675 # define GLM_VECTOR_CALL
676 # endif
677 #elif GLM_COMPILER & GLM_COMPILER_CUDA
678 # define GLM_DEPRECATED
679 # define GLM_ALIGN(x) __align__(x)
680 # define GLM_ALIGNED_STRUCT(x) struct __align__(x)
681 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name __align__(x)
682 # define GLM_RESTRICT_FUNC __restrict__
683 # define GLM_RESTRICT __restrict__
684 # define GLM_VECTOR_CALL
685 #else
686 # define GLM_DEPRECATED
687 # define GLM_ALIGN
688 # define GLM_ALIGNED_STRUCT(x) struct
689 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name
690 # define GLM_RESTRICT_FUNC
691 # define GLM_RESTRICT
692 # define GLM_VECTOR_CALL
693 #endif//GLM_COMPILER
694
695 #if GLM_HAS_DEFAULTED_FUNCTIONS
696 # define GLM_DEFAULT = default
697 #else
698 # define GLM_DEFAULT
699 #endif
700
701 #if GLM_HAS_CONSTEXPR || GLM_HAS_CONSTEXPR_PARTIAL
702 # define GLM_CONSTEXPR constexpr
703 # if ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER <= GLM_COMPILER_VC14)) // Visual C++ has a bug #594 https://github.com/g-truc/glm/issues/594
704 # define GLM_CONSTEXPR_CTOR
705 # else
706 # define GLM_CONSTEXPR_CTOR constexpr
707 # endif
708 #else
709 # define GLM_CONSTEXPR
710 # define GLM_CONSTEXPR_CTOR
711 #endif
712
713 #if GLM_HAS_CONSTEXPR
714 # define GLM_RELAXED_CONSTEXPR constexpr
715 #else
716 # define GLM_RELAXED_CONSTEXPR const
717 #endif
718
719 #if GLM_ARCH == GLM_ARCH_PURE
720 # define GLM_CONSTEXPR_SIMD GLM_CONSTEXPR_CTOR
721 #else
722 # define GLM_CONSTEXPR_SIMD
723 #endif
724
725 #ifdef GLM_FORCE_EXPLICIT_CTOR
726 # define GLM_EXPLICIT explicit
727 #else
728 # define GLM_EXPLICIT
729 #endif
730
732
733 #define GLM_HAS_ALIGNED_TYPE GLM_HAS_UNRESTRICTED_UNIONS
734
736 // Length type: all length functions returns a length_t type.
737 // When GLM_FORCE_SIZE_T_LENGTH is defined, length_t is a typedef of size_t otherwise
738 // length_t is a typedef of int like GLSL defines it.
739
740 // User define: GLM_FORCE_SIZE_T_LENGTH
741
742 namespace glm
743 {
744 using std::size_t;
745 # if defined(GLM_FORCE_SIZE_T_LENGTH)
746 typedef size_t length_t;
747 # else
748 typedef int length_t;
749 # endif
750 }//namespace glm
751
752 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_SIZE_T_LENGTH)
753 # define GLM_MESSAGE_FORCE_SIZE_T_LENGTH
754 # if defined GLM_FORCE_SIZE_T_LENGTH
755 # pragma message("GLM: .length() returns glm::length_t, a typedef of std::size_t")
756 # else
757 # pragma message("GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification")
758 # endif
759 #endif//GLM_MESSAGES
760
762 // countof
763
764 #if GLM_HAS_CONSTEXPR_PARTIAL
765 namespace glm
766 {
767 template<typename T, std::size_t N>
768 constexpr std::size_t countof(T const (&)[N])
769 {
770 return N;
771 }
772 }//namespace glm
773 # define GLM_COUNTOF(arr) glm::countof(arr)
774 #elif defined(_MSC_VER)
775 # define GLM_COUNTOF(arr) _countof(arr)
776 #else
777 # define GLM_COUNTOF(arr) sizeof(arr) / sizeof(arr[0])
778 #endif
779
781 // Check inclusions of different versions of GLM
782
783 #elif ((GLM_SETUP_INCLUDED != GLM_VERSION) && !defined(GLM_FORCE_IGNORE_VERSION))
784 # error "GLM error: A different version of GLM is already included. Define GLM_FORCE_IGNORE_VERSION before including GLM headers to ignore this error."
785 #elif GLM_SETUP_INCLUDED == GLM_VERSION
786
787 #endif//GLM_SETUP_INCLUDED
glm
Definition: common.hpp:20