You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

694 lines
25 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref core
  24. /// @file glm/core/setup.hpp
  25. /// @date 2006-11-13 / 2011-06-15
  26. /// @author Christophe Riccio
  27. ///////////////////////////////////////////////////////////////////////////////////
  28. #ifndef glm_setup
  29. #define glm_setup
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////
  31. // Version
  32. #define GLM_VERSION 94
  33. #define GLM_VERSION_MAJOR 0
  34. #define GLM_VERSION_MINOR 9
  35. #define GLM_VERSION_PATCH 4
  36. #define GLM_VERSION_REVISION 7
  37. ///////////////////////////////////////////////////////////////////////////////////////////////////
  38. // Platform
  39. #define GLM_PLATFORM_UNKNOWN 0x00000000
  40. #define GLM_PLATFORM_WINDOWS 0x00010000
  41. #define GLM_PLATFORM_LINUX 0x00020000
  42. #define GLM_PLATFORM_APPLE 0x00040000
  43. //#define GLM_PLATFORM_IOS 0x00080000
  44. #define GLM_PLATFORM_ANDROID 0x00100000
  45. #define GLM_PLATFORM_CHROME_NACL 0x00200000
  46. #define GLM_PLATFORM_UNIX 0x00400000
  47. #define GLM_PLATFORM_QNXNTO 0x00800000
  48. #define GLM_PLATFORM_WINCE 0x01000000
  49. #ifdef GLM_FORCE_PLATFORM_UNKNOWN
  50. # define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
  51. #elif defined(__QNXNTO__)
  52. # define GLM_PLATFORM GLM_PLATFORM_QNXNTO
  53. #elif defined(__APPLE__)
  54. # define GLM_PLATFORM GLM_PLATFORM_APPLE
  55. #elif defined(WINCE)
  56. # define GLM_PLATFORM GLM_PLATFORM_WINCE
  57. #elif defined(_WIN32)
  58. # define GLM_PLATFORM GLM_PLATFORM_WINDOWS
  59. #elif defined(__native_client__)
  60. # define GLM_PLATFORM GLM_PLATFORM_CHROME_NACL
  61. #elif defined(__ANDROID__)
  62. # define GLM_PLATFORM GLM_PLATFORM_ANDROID
  63. #elif defined(__linux)
  64. # define GLM_PLATFORM GLM_PLATFORM_LINUX
  65. #elif defined(__unix)
  66. # define GLM_PLATFORM GLM_PLATFORM_UNIX
  67. #else
  68. # define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
  69. #endif//
  70. // Report platform detection
  71. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_PLATFORM_DISPLAYED))
  72. # define GLM_MESSAGE_PLATFORM_DISPLAYED
  73. # if(GLM_PLATFORM & GLM_PLATFORM_QNXNTO)
  74. # pragma message("GLM: QNX platform detected")
  75. //# elif(GLM_PLATFORM & GLM_PLATFORM_IOS)
  76. //# pragma message("GLM: iOS platform detected")
  77. # elif(GLM_PLATFORM & GLM_PLATFORM_APPLE)
  78. # pragma message("GLM: Apple platform detected")
  79. # elif(GLM_PLATFORM & GLM_PLATFORM_WINCE)
  80. # pragma message("GLM: WinCE platform detected")
  81. # elif(GLM_PLATFORM & GLM_PLATFORM_WINDOWS)
  82. # pragma message("GLM: Windows platform detected")
  83. # elif(GLM_PLATFORM & GLM_PLATFORM_CHROME_NACL)
  84. # pragma message("GLM: Native Client detected")
  85. # elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
  86. # pragma message("GLM: Android platform detected")
  87. # elif(GLM_PLATFORM & GLM_PLATFORM_LINUX)
  88. # pragma message("GLM: Linux platform detected")
  89. # elif(GLM_PLATFORM & GLM_PLATFORM_UNIX)
  90. # pragma message("GLM: UNIX platform detected")
  91. # elif(GLM_PLATFORM & GLM_PLATFORM_UNKNOWN)
  92. # pragma message("GLM: platform unknown")
  93. # else
  94. # pragma message("GLM: platform not detected")
  95. # endif
  96. #endif//GLM_MESSAGE
  97. ///////////////////////////////////////////////////////////////////////////////////////////////////
  98. // Compiler
  99. // User defines: GLM_FORCE_COMPILER_UNKNOWN
  100. // TODO ? __llvm__
  101. #define GLM_COMPILER_UNKNOWN 0x00000000
  102. // Intel
  103. #define GLM_COMPILER_INTEL 0x00100000
  104. #define GLM_COMPILER_INTEL9 0x00100010
  105. #define GLM_COMPILER_INTEL10_0 0x00100020
  106. #define GLM_COMPILER_INTEL10_1 0x00100030
  107. #define GLM_COMPILER_INTEL11_0 0x00100040
  108. #define GLM_COMPILER_INTEL11_1 0x00100050
  109. #define GLM_COMPILER_INTEL12_0 0x00100060
  110. #define GLM_COMPILER_INTEL12_1 0x00100070
  111. #define GLM_COMPILER_INTEL13_0 0x00100080
  112. // Visual C++ defines
  113. #define GLM_COMPILER_VC 0x01000000
  114. #define GLM_COMPILER_VC2 0x01000010
  115. #define GLM_COMPILER_VC4 0x01000020
  116. #define GLM_COMPILER_VC5 0x01000030
  117. #define GLM_COMPILER_VC6 0x01000040
  118. #define GLM_COMPILER_VC2002 0x01000050
  119. #define GLM_COMPILER_VC2003 0x01000060
  120. #define GLM_COMPILER_VC2005 0x01000070
  121. #define GLM_COMPILER_VC2008 0x01000080
  122. #define GLM_COMPILER_VC2010 0x01000090
  123. #define GLM_COMPILER_VC2012 0x010000A0
  124. #define GLM_COMPILER_VC2013 0x010000B0
  125. // GCC defines
  126. #define GLM_COMPILER_GCC 0x02000000
  127. #define GLM_COMPILER_GCC_LLVM 0x02000001
  128. #define GLM_COMPILER_GCC_CLANG 0x02000002
  129. #define GLM_COMPILER_GCC30 0x02000010
  130. #define GLM_COMPILER_GCC31 0x02000020
  131. #define GLM_COMPILER_GCC32 0x02000030
  132. #define GLM_COMPILER_GCC33 0x02000040
  133. #define GLM_COMPILER_GCC34 0x02000050
  134. #define GLM_COMPILER_GCC35 0x02000060
  135. #define GLM_COMPILER_GCC40 0x02000070
  136. #define GLM_COMPILER_GCC41 0x02000080
  137. #define GLM_COMPILER_GCC42 0x02000090
  138. #define GLM_COMPILER_GCC43 0x020000A0
  139. #define GLM_COMPILER_GCC44 0x020000B0
  140. #define GLM_COMPILER_GCC45 0x020000C0
  141. #define GLM_COMPILER_GCC46 0x020000D0
  142. #define GLM_COMPILER_GCC47 0x020000E0
  143. #define GLM_COMPILER_GCC48 0x020000F0
  144. #define GLM_COMPILER_GCC49 0x02000100
  145. // G++ command line to display defined
  146. // echo "" | g++ -E -dM -x c++ - | sort
  147. // Borland C++ defines. How to identify BC?
  148. #define GLM_COMPILER_BC 0x04000000
  149. #define GLM_COMPILER_BCB4 0x04000100
  150. #define GLM_COMPILER_BCB5 0x04000200
  151. #define GLM_COMPILER_BCB6 0x04000300
  152. //#define GLM_COMPILER_BCBX 0x04000400 // What's the version value?
  153. #define GLM_COMPILER_BCB2009 0x04000500
  154. // CodeWarrior
  155. #define GLM_COMPILER_CODEWARRIOR 0x08000000
  156. // CUDA
  157. #define GLM_COMPILER_CUDA 0x10000000
  158. #define GLM_COMPILER_CUDA30 0x10000010
  159. #define GLM_COMPILER_CUDA31 0x10000020
  160. #define GLM_COMPILER_CUDA32 0x10000030
  161. #define GLM_COMPILER_CUDA40 0x10000040
  162. #define GLM_COMPILER_CUDA41 0x10000050
  163. #define GLM_COMPILER_CUDA42 0x10000060
  164. // Clang
  165. #define GLM_COMPILER_CLANG 0x20000000
  166. #define GLM_COMPILER_CLANG26 0x20000010
  167. #define GLM_COMPILER_CLANG27 0x20000020
  168. #define GLM_COMPILER_CLANG28 0x20000030
  169. #define GLM_COMPILER_CLANG29 0x20000040
  170. #define GLM_COMPILER_CLANG30 0x20000050
  171. #define GLM_COMPILER_CLANG31 0x20000060
  172. #define GLM_COMPILER_CLANG32 0x20000070
  173. #define GLM_COMPILER_CLANG33 0x20000080
  174. #define GLM_COMPILER_CLANG40 0x20000090
  175. #define GLM_COMPILER_CLANG41 0x200000A0
  176. #define GLM_COMPILER_CLANG42 0x200000B0
  177. #define GLM_COMPILER_CLANG43 0x200000C0
  178. // LLVM GCC
  179. #define GLM_COMPILER_LLVM_GCC 0x40000000
  180. // Build model
  181. #define GLM_MODEL_32 0x00000010
  182. #define GLM_MODEL_64 0x00000020
  183. // Force generic C++ compiler
  184. #ifdef GLM_FORCE_COMPILER_UNKNOWN
  185. # define GLM_COMPILER GLM_COMPILER_UNKNOWN
  186. #elif defined(__INTEL_COMPILER)
  187. # if __INTEL_COMPILER == 900
  188. # define GLM_COMPILER GLM_COMPILER_INTEL9
  189. # elif __INTEL_COMPILER == 1000
  190. # define GLM_COMPILER GLM_COMPILER_INTEL10_0
  191. # elif __INTEL_COMPILER == 1010
  192. # define GLM_COMPILER GLM_COMPILER_INTEL10_1
  193. # elif __INTEL_COMPILER == 1100
  194. # define GLM_COMPILER GLM_COMPILER_INTEL11_0
  195. # elif __INTEL_COMPILER == 1110
  196. # define GLM_COMPILER GLM_COMPILER_INTEL11_1
  197. # elif __INTEL_COMPILER == 1200
  198. # define GLM_COMPILER GLM_COMPILER_INTEL12_0
  199. # elif __INTEL_COMPILER == 1210
  200. # define GLM_COMPILER GLM_COMPILER_INTEL12_1
  201. # elif __INTEL_COMPILER >= 1300
  202. # define GLM_COMPILER GLM_COMPILER_INTEL13_0
  203. # else
  204. # define GLM_COMPILER GLM_COMPILER_INTEL
  205. # endif
  206. // CUDA
  207. #elif defined(__CUDACC__)
  208. # if CUDA_VERSION < 3000
  209. # error "GLM requires CUDA 3.0 or higher"
  210. # else
  211. # define GLM_COMPILER GLM_COMPILER_CUDA
  212. # endif
  213. // Visual C++
  214. #elif defined(_MSC_VER)
  215. # if _MSC_VER < 1400
  216. # error "GLM requires Visual C++ 2005 or higher"
  217. # elif _MSC_VER == 1400
  218. # define GLM_COMPILER GLM_COMPILER_VC2005
  219. # elif _MSC_VER == 1500
  220. # define GLM_COMPILER GLM_COMPILER_VC2008
  221. # elif _MSC_VER == 1600
  222. # define GLM_COMPILER GLM_COMPILER_VC2010
  223. # elif _MSC_VER == 1700
  224. # define GLM_COMPILER GLM_COMPILER_VC2012
  225. # elif _MSC_VER >= 1800
  226. # define GLM_COMPILER GLM_COMPILER_VC2013
  227. # else//_MSC_VER
  228. # define GLM_COMPILER GLM_COMPILER_VC
  229. # endif//_MSC_VER
  230. // Clang
  231. #elif defined(__clang__)
  232. # if (__clang_major__ <= 1) || ((__clang_major__ == 2) && (__clang_minor__ < 6))
  233. # error "GLM requires Clang 2.6 or higher"
  234. # elif(__clang_major__ == 2) && (__clang_minor__ == 6)
  235. # define GLM_COMPILER GLM_COMPILER_CLANG26
  236. # elif(__clang_major__ == 2) && (__clang_minor__ == 7)
  237. # define GLM_COMPILER GLM_COMPILER_CLANG27
  238. # elif(__clang_major__ == 2) && (__clang_minor__ == 8)
  239. # define GLM_COMPILER GLM_COMPILER_CLANG28
  240. # elif(__clang_major__ == 2) && (__clang_minor__ == 9)
  241. # define GLM_COMPILER GLM_COMPILER_CLANG29
  242. # elif(__clang_major__ == 3) && (__clang_minor__ == 0)
  243. # define GLM_COMPILER GLM_COMPILER_CLANG30
  244. # elif(__clang_major__ == 3) && (__clang_minor__ == 1)
  245. # define GLM_COMPILER GLM_COMPILER_CLANG31
  246. # elif(__clang_major__ == 3) && (__clang_minor__ == 2)
  247. # define GLM_COMPILER GLM_COMPILER_CLANG32
  248. # elif(__clang_major__ == 3) && (__clang_minor__ == 3)
  249. # define GLM_COMPILER GLM_COMPILER_CLANG33
  250. # elif(__clang_major__ == 4) && (__clang_minor__ == 0)
  251. # define GLM_COMPILER GLM_COMPILER_CLANG40
  252. # elif(__clang_major__ == 4) && (__clang_minor__ == 1)
  253. # define GLM_COMPILER GLM_COMPILER_CLANG41
  254. # elif(__clang_major__ == 4) && (__clang_minor__ == 2)
  255. # define GLM_COMPILER GLM_COMPILER_CLANG42
  256. # elif(__clang_major__ == 4) && (__clang_minor__ >= 3)
  257. # define GLM_COMPILER GLM_COMPILER_CLANG43
  258. # elif(__clang_major__ > 4)
  259. # define GLM_COMPILER GLM_COMPILER_CLANG43
  260. # else
  261. # define GLM_COMPILER GLM_COMPILER_CLANG
  262. # endif
  263. // G++
  264. #elif(defined(__GNUC__) || defined(__MINGW32__))// || defined(__llvm__) || defined(__clang__)
  265. # if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2)
  266. # define GLM_COMPILER GLM_COMPILER_GCC32
  267. # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 3)
  268. # define GLM_COMPILER GLM_COMPILER_GCC33
  269. # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 4)
  270. # define GLM_COMPILER GLM_COMPILER_GCC34
  271. # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 5)
  272. # define GLM_COMPILER GLM_COMPILER_GCC35
  273. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 0)
  274. # define GLM_COMPILER (GLM_COMPILER_GCC40)
  275. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 1)
  276. # define GLM_COMPILER (GLM_COMPILER_GCC41)
  277. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
  278. # define GLM_COMPILER (GLM_COMPILER_GCC42)
  279. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
  280. # define GLM_COMPILER (GLM_COMPILER_GCC43)
  281. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
  282. # define GLM_COMPILER (GLM_COMPILER_GCC44)
  283. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 5)
  284. # define GLM_COMPILER (GLM_COMPILER_GCC45)
  285. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
  286. # define GLM_COMPILER (GLM_COMPILER_GCC46)
  287. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
  288. # define GLM_COMPILER (GLM_COMPILER_GCC47)
  289. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
  290. # define GLM_COMPILER (GLM_COMPILER_GCC48)
  291. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)
  292. # define GLM_COMPILER (GLM_COMPILER_GCC49)
  293. # elif (__GNUC__ > 4 )
  294. # define GLM_COMPILER (GLM_COMPILER_GCC49)
  295. # else
  296. # define GLM_COMPILER (GLM_COMPILER_GCC)
  297. # endif
  298. // Borland C++
  299. #elif defined(_BORLANDC_)
  300. # define GLM_COMPILER GLM_COMPILER_BC
  301. // Codewarrior
  302. #elif defined(__MWERKS__)
  303. # define GLM_COMPILER GLM_COMPILER_CODEWARRIOR
  304. #else
  305. # define GLM_COMPILER GLM_COMPILER_UNKNOWN
  306. #endif
  307. #ifndef GLM_COMPILER
  308. #error "GLM_COMPILER undefined, your compiler may not be supported by GLM. Add #define GLM_COMPILER 0 to ignore this message."
  309. #endif//GLM_COMPILER
  310. // Report compiler detection
  311. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPILER_DISPLAYED))
  312. # define GLM_MESSAGE_COMPILER_DISPLAYED
  313. # if(GLM_COMPILER & GLM_COMPILER_CUDA)
  314. # pragma message("GLM: CUDA compiler detected")
  315. # elif(GLM_COMPILER & GLM_COMPILER_VC)
  316. # pragma message("GLM: Visual C++ compiler detected")
  317. # elif(GLM_COMPILER & GLM_COMPILER_CLANG)
  318. # pragma message("GLM: Clang compiler detected")
  319. # elif(GLM_COMPILER & GLM_COMPILER_LLVM_GCC)
  320. # pragma message("GLM: LLVM GCC compiler detected")
  321. # elif(GLM_COMPILER & GLM_COMPILER_GCC)
  322. # if(GLM_COMPILER == GLM_COMPILER_GCC_LLVM)
  323. # pragma message("GLM: LLVM GCC compiler detected")
  324. # elif(GLM_COMPILER == GLM_COMPILER_GCC_CLANG)
  325. # pragma message("GLM: CLANG compiler detected")
  326. # else
  327. # pragma message("GLM: GCC compiler detected")
  328. # endif
  329. # elif(GLM_COMPILER & GLM_COMPILER_BC)
  330. # pragma message("GLM: Borland compiler detected but not supported")
  331. # elif(GLM_COMPILER & GLM_COMPILER_CODEWARRIOR)
  332. # pragma message("GLM: Codewarrior compiler detected but not supported")
  333. # else
  334. # pragma message("GLM: Compiler not detected")
  335. # endif
  336. #endif//GLM_MESSAGE
  337. /////////////////
  338. // Build model //
  339. #if(defined(__arch64__) || defined(__LP64__) || defined(_M_X64) || defined(__ppc64__) || defined(__x86_64__))
  340. # define GLM_MODEL GLM_MODEL_64
  341. #elif(defined(__i386__) || defined(__ppc__))
  342. # define GLM_MODEL GLM_MODEL_32
  343. #else
  344. # define GLM_MODEL GLM_MODEL_32
  345. #endif//
  346. #if(!defined(GLM_MODEL) && GLM_COMPILER != 0)
  347. # error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
  348. #endif//GLM_MODEL
  349. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_MODEL_DISPLAYED))
  350. # define GLM_MESSAGE_MODEL_DISPLAYED
  351. # if(GLM_MODEL == GLM_MODEL_64)
  352. # pragma message("GLM: 64 bits model")
  353. # elif(GLM_MODEL == GLM_MODEL_32)
  354. # pragma message("GLM: 32 bits model")
  355. # endif//GLM_MODEL
  356. #endif//GLM_MESSAGE
  357. /////////////////
  358. // C++ Version //
  359. // User defines: GLM_FORCE_CXX98
  360. #define GLM_LANG_CXX (0 << 0)
  361. #define GLM_LANG_CXX98 ((1 << 1) | GLM_LANG_CXX)
  362. #define GLM_LANG_CXX03 ((1 << 2) | GLM_LANG_CXX98)
  363. #define GLM_LANG_CXX0X ((1 << 3) | GLM_LANG_CXX03)
  364. #define GLM_LANG_CXX11 ((1 << 4) | GLM_LANG_CXX0X)
  365. #define GLM_LANG_CXXMS (1 << 5)
  366. #define GLM_LANG_CXXGNU (1 << 6)
  367. #if(defined(GLM_FORCE_CXX11))
  368. # define GLM_LANG GLM_LANG_CXX11
  369. #elif(defined(GLM_FORCE_CXX03))
  370. # define GLM_LANG GLM_LANG_CXX03
  371. #elif(defined(GLM_FORCE_CXX98))
  372. # define GLM_LANG GLM_LANG_CXX98
  373. #else
  374. # if(__cplusplus >= 201103L)
  375. # define GLM_LANG GLM_LANG_CXX11
  376. # elif((GLM_COMPILER & GLM_COMPILER_CLANG) == GLM_COMPILER_CLANG)
  377. # if(GLM_PLATFORM == GLM_PLATFORM_APPLE)
  378. # define GLM_DETAIL_MAJOR 1
  379. # else
  380. # define GLM_DETAIL_MAJOR 0
  381. # endif
  382. # if(__clang_major__ < (2 + GLM_DETAIL_MAJOR))
  383. # define GLM_LANG GLM_LANG_CXX
  384. # elif(__has_feature(cxx_auto_type))
  385. # define GLM_LANG GLM_LANG_CXX0X
  386. # else
  387. # define GLM_LANG GLM_LANG_CXX98
  388. # endif
  389. # elif((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC)
  390. # if defined(__GXX_EXPERIMENTAL_CXX0X__)
  391. # define GLM_LANG GLM_LANG_CXX0X
  392. # else
  393. # define GLM_LANG GLM_LANG_CXX98
  394. # endif
  395. # elif(((GLM_COMPILER & GLM_COMPILER_VC) == GLM_COMPILER_VC) && defined(_MSC_EXTENSIONS))
  396. # define GLM_LANG GLM_LANG_CXXMS
  397. # elif(((GLM_COMPILER & GLM_COMPILER_VC) == GLM_COMPILER_VC) && !defined(_MSC_EXTENSIONS))
  398. # if(GLM_COMPILER >= GLM_COMPILER_VC2010)
  399. # define GLM_LANG GLM_LANG_CXX0X
  400. # else
  401. # define GLM_LANG GLM_LANG_CXX98
  402. # endif
  403. # elif(__cplusplus >= 199711L)
  404. # define GLM_LANG GLM_LANG_CXX98
  405. # else
  406. # define GLM_LANG GLM_LANG_CXX
  407. # endif
  408. #endif
  409. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED))
  410. # define GLM_MESSAGE_LANG_DISPLAYED
  411. # if(GLM_LANG == GLM_LANG_CXX98)
  412. # pragma message("GLM: C++98")
  413. # elif(GLM_LANG == GLM_LANG_CXX03)
  414. # pragma message("GLM: C++03")
  415. # elif(GLM_LANG == GLM_LANG_CXX0X)
  416. # pragma message("GLM: C++0x")
  417. # elif(GLM_LANG == GLM_LANG_CXX11)
  418. # pragma message("GLM: C++11")
  419. # elif(GLM_LANG == GLM_LANG_CXXGNU)
  420. # pragma message("GLM: C++ with GNU language extensions")
  421. # elif(GLM_LANG == GLM_LANG_CXXMS)
  422. # pragma message("GLM: C++ with VC language extensions")
  423. # else
  424. # pragma message("GLM: C++ language undetected")
  425. # endif//GLM_MODEL
  426. #endif//GLM_MESSAGE
  427. /////////////////
  428. // Platform
  429. // User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_AVX
  430. #define GLM_ARCH_PURE 0x0000
  431. #define GLM_ARCH_SSE2 0x0001
  432. #define GLM_ARCH_SSE3 0x0002// | GLM_ARCH_SSE2
  433. #define GLM_ARCH_SSE4 0x0004// | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
  434. #define GLM_ARCH_AVX 0x0008// | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
  435. #define GLM_ARCH_AVX2 0x0010// | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
  436. #if(defined(GLM_FORCE_PURE))
  437. # define GLM_ARCH GLM_ARCH_PURE
  438. #elif(defined(GLM_FORCE_AVX2))
  439. # define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  440. #elif(defined(GLM_FORCE_AVX))
  441. # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  442. #elif(defined(GLM_FORCE_SSE4))
  443. # define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  444. #elif(defined(GLM_FORCE_SSE3))
  445. # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  446. #elif(defined(GLM_FORCE_SSE2))
  447. # define GLM_ARCH (GLM_ARCH_SSE2)
  448. #elif((GLM_COMPILER & GLM_COMPILER_VC) && (defined(_M_IX86) || defined(_M_X64)))
  449. # if(GLM_PLATFORM == GLM_PLATFORM_WINCE)
  450. # define GLM_ARCH GLM_ARCH_PURE
  451. # elif(defined(_M_CEE_PURE))
  452. # define GLM_ARCH GLM_ARCH_PURE
  453. /* TODO: Explore auto detection of instruction set support
  454. # elif(defined(_M_IX86_FP))
  455. # if(_M_IX86_FP >= 3)
  456. # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  457. # elif(_M_IX86_FP >= 2)
  458. # define GLM_ARCH (GLM_ARCH_SSE2)
  459. # else
  460. # define GLM_ARCH GLM_ARCH_PURE
  461. # endif
  462. */
  463. # elif(GLM_COMPILER >= GLM_COMPILER_VC2012)
  464. # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  465. # elif(GLM_COMPILER >= GLM_COMPILER_VC2010)
  466. # if(_MSC_FULL_VER >= 160031118) //160031118: VC2010 SP1 beta full version
  467. # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)//GLM_ARCH_AVX (Require SP1)
  468. # else
  469. # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  470. # endif
  471. # elif(GLM_COMPILER >= GLM_COMPILER_VC2008)
  472. # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  473. # elif(GLM_COMPILER >= GLM_COMPILER_VC2005)
  474. # define GLM_ARCH GLM_ARCH_SSE2
  475. # else
  476. # define GLM_ARCH GLM_ARCH_PURE
  477. # endif
  478. #elif((GLM_PLATFORM & GLM_PLATFORM_APPLE) && (GLM_COMPILER & GLM_COMPILER_GCC))
  479. # define GLM_ARCH GLM_ARCH_PURE
  480. #elif(((GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__))) || (GLM_COMPILER & GLM_COMPILER_LLVM_GCC))
  481. # define GLM_ARCH (GLM_ARCH_PURE \
  482. | (defined(__AVX2__) ? GLM_ARCH_AVX2 : 0) \
  483. | (defined(__AVX__) ? GLM_ARCH_AVX : 0) \
  484. | (defined(__SSE4__) ? GLM_ARCH_SSE4 : 0) \
  485. | (defined(__SSE3__) ? GLM_ARCH_SSE3 : 0) \
  486. | (defined(__SSE2__) ? GLM_ARCH_SSE2 : 0))
  487. #else
  488. # define GLM_ARCH GLM_ARCH_PURE
  489. #endif
  490. // With MinGW-W64, including intrinsic headers before intrin.h will produce some errors. The problem is
  491. // that windows.h (and maybe other headers) will silently include intrin.h, which of course causes problems.
  492. // To fix, we just explicitly include intrin.h here.
  493. #if defined(__MINGW32__) && (GLM_ARCH != GLM_ARCH_PURE)
  494. # include <intrin.h>
  495. #endif
  496. //#if(GLM_ARCH != GLM_ARCH_PURE)
  497. #if(GLM_ARCH & GLM_ARCH_AVX2)
  498. # include <immintrin.h>
  499. #endif//GLM_ARCH
  500. #if(GLM_ARCH & GLM_ARCH_AVX)
  501. # include <immintrin.h>
  502. #endif//GLM_ARCH
  503. #if(GLM_ARCH & GLM_ARCH_SSE4)
  504. # include <smmintrin.h>
  505. #endif//GLM_ARCH
  506. #if(GLM_ARCH & GLM_ARCH_SSE3)
  507. # include <pmmintrin.h>
  508. #endif//GLM_ARCH
  509. #if(GLM_ARCH & GLM_ARCH_SSE2)
  510. # include <emmintrin.h>
  511. #endif//GLM_ARCH
  512. //#endif//(GLM_ARCH != GLM_ARCH_PURE)
  513. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_ARCH_DISPLAYED))
  514. # define GLM_MESSAGE_ARCH_DISPLAYED
  515. # if(GLM_ARCH == GLM_ARCH_PURE)
  516. # pragma message("GLM: Platform independent")
  517. # elif(GLM_ARCH & GLM_ARCH_SSE2)
  518. # pragma message("GLM: SSE2 instruction set")
  519. # elif(GLM_ARCH & GLM_ARCH_SSE3)
  520. # pragma message("GLM: SSE3 instruction set")
  521. # elif(GLM_ARCH & GLM_ARCH_SSE4)
  522. # pragma message("GLM: SSE4 instruction set")
  523. # elif(GLM_ARCH & GLM_ARCH_AVX)
  524. # pragma message("GLM: AVX instruction set")
  525. # elif(GLM_ARCH & GLM_ARCH_AVX2)
  526. # pragma message("GLM: AVX2 instruction set")
  527. # endif//GLM_ARCH
  528. #endif//GLM_MESSAGE
  529. ///////////////////////////////////////////////////////////////////////////////////////////////////
  530. // Support check macros
  531. #define GLM_SUPPORT_ANONYMOUS_UNION() \
  532. ((GLM_LANG & GLM_LANG_CXX98) == GLM_LANG_CXX98)
  533. //#define GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() <backslash>
  534. // (((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_LANG & GLM_LANG_CXXMS) == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X)))
  535. #define GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() \
  536. (((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || ((GLM_COMPILER & GLM_COMPILER_VC) && ((GLM_LANG & GLM_LANG_CXXMS) == GLM_LANG_CXXMS)) || ((GLM_LANG == GLM_LANG_CXX0X) == GLM_LANG_CXX0X))
  537. #define GLM_SUPPORT_SWIZZLE_OPERATOR() \
  538. (/*defined(GLM_SWIZZLE) && */GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE())
  539. #define GLM_SUPPORT_SWIZZLE_FUNCTION() defined(GLM_SWIZZLE)
  540. ///////////////////////////////////////////////////////////////////////////////////////////////////
  541. // Components
  542. //#define GLM_FORCE_ONLY_XYZW
  543. #define GLM_COMPONENT_ONLY_XYZW 0 // To disable multiple vector component names access.
  544. #define GLM_COMPONENT_CXX98 1 //
  545. #define GLM_COMPONENT_CXX11 2 // To use anonymous union to provide multiple component names access for class valType. Visual C++ only.
  546. #if(GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() && !defined(GLM_FORCE_ONLY_XYZW))
  547. # define GLM_COMPONENT GLM_COMPONENT_CXX11
  548. #elif(GLM_SUPPORT_ANONYMOUS_UNION() && !defined(GLM_FORCE_ONLY_XYZW))
  549. # define GLM_COMPONENT GLM_COMPONENT_CXX98
  550. #else
  551. # define GLM_COMPONENT GLM_COMPONENT_ONLY_XYZW
  552. #endif
  553. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPONENT_DISPLAYED))
  554. # define GLM_MESSAGE_COMPONENT_DISPLAYED
  555. # if(GLM_COMPONENT == GLM_COMPONENT_CXX98)
  556. # pragma message("GLM: x,y,z,w; r,g,b,a; s,t,p,q component names except of half based vector types")
  557. # elif(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
  558. # pragma message("GLM: x,y,z,w component names for all vector types")
  559. # elif(GLM_COMPONENT == GLM_COMPONENT_CXX11)
  560. # pragma message("GLM: x,y,z,w; r,g,b,a; s,t,p,q component names for all vector types")
  561. # else
  562. # error "GLM: GLM_COMPONENT value unknown"
  563. # endif//GLM_MESSAGE_COMPONENT_DISPLAYED
  564. #endif//GLM_MESSAGE
  565. ///////////////////////////////////////////////////////////////////////////////////////////////////
  566. // Radians
  567. //#define GLM_FORCE_RADIANS
  568. ///////////////////////////////////////////////////////////////////////////////////////////////////
  569. // Static assert
  570. #if(GLM_LANG == GLM_LANG_CXX0X)
  571. # define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
  572. #elif(defined(BOOST_STATIC_ASSERT))
  573. # define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)
  574. #elif(GLM_COMPILER & GLM_COMPILER_VC)
  575. # define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
  576. #else
  577. # define GLM_STATIC_ASSERT(x, message)
  578. # define GLM_STATIC_ASSERT_NULL
  579. #endif//GLM_LANG
  580. ///////////////////////////////////////////////////////////////////////////////////////////////////
  581. // Qualifiers
  582. // User defines: GLM_FORCE_INLINE GLM_FORCE_CUDA
  583. #if(defined(GLM_FORCE_CUDA) || (GLM_COMPILER & GLM_COMPILER_CUDA))
  584. # define GLM_CUDA_FUNC_DEF __device__ __host__
  585. # define GLM_CUDA_FUNC_DECL __device__ __host__
  586. #else
  587. # define GLM_CUDA_FUNC_DEF
  588. # define GLM_CUDA_FUNC_DECL
  589. #endif
  590. #if GLM_COMPILER & GLM_COMPILER_GCC
  591. # define GLM_VAR_USED __attribute__ ((unused))
  592. #else
  593. # define GLM_VAR_USED
  594. #endif
  595. #if(defined(GLM_FORCE_INLINE))
  596. # if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
  597. # define GLM_INLINE __forceinline
  598. # elif((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC34))
  599. # define GLM_INLINE __attribute__((always_inline))
  600. # elif(GLM_COMPILER & GLM_COMPILER_CLANG)
  601. # define GLM_INLINE __attribute__((always_inline))
  602. # else
  603. # define GLM_INLINE inline
  604. # endif//GLM_COMPILER
  605. #else
  606. # define GLM_INLINE inline
  607. #endif//defined(GLM_FORCE_INLINE)
  608. #define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL
  609. #define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE
  610. ///////////////////////////////////////////////////////////////////////////////////////////////////
  611. // Swizzle operators
  612. // User defines: GLM_SWIZZLE
  613. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED))
  614. # define GLM_MESSAGE_SWIZZLE_DISPLAYED
  615. # if(GLM_SUPPORT_SWIZZLE_OPERATOR())
  616. # pragma message("GLM: Swizzling operators enabled")
  617. # elif(GLM_SUPPORT_SWIZZLE_FUNCTION())
  618. # pragma message("GLM: Swizzling operators supported through swizzling functions")
  619. # else
  620. # pragma message("GLM: Swizzling operators disabled")
  621. # endif
  622. #endif//GLM_MESSAGE
  623. #endif//glm_setup