setup.hpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2006-11-13
  5. // Updated : 2011-01-26
  6. // Licence : This source is under MIT License
  7. // File : glm/setup.hpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #ifndef glm_setup
  10. #define glm_setup
  11. ///////////////////////////////////////////////////////////////////////////////////////////////////
  12. // Version
  13. #define GLM_VERSION 91
  14. #define GLM_VERSION_MAJOR 0
  15. #define GLM_VERSION_MINOR 9
  16. #define GLM_VERSION_PATCH 1
  17. #define GLM_VERSION_REVISION A
  18. ///////////////////////////////////////////////////////////////////////////////////////////////////
  19. // Compiler
  20. // User defines: GLM_FORCE_COMPILER_UNKNOWN
  21. #define GLM_COMPILER_UNKNOWN 0x00000000
  22. // Visual C++ defines
  23. #define GLM_COMPILER_VC 0x01000000
  24. #define GLM_COMPILER_VC2 0x01000010
  25. #define GLM_COMPILER_VC4 0x01000020
  26. #define GLM_COMPILER_VC5 0x01000030
  27. #define GLM_COMPILER_VC6 0x01000040
  28. #define GLM_COMPILER_VC2002 0x01000050
  29. #define GLM_COMPILER_VC2003 0x01000060
  30. #define GLM_COMPILER_VC2005 0x01000070
  31. #define GLM_COMPILER_VC2008 0x01000080
  32. #define GLM_COMPILER_VC2010 0x01000090
  33. // GCC defines
  34. #define GLM_COMPILER_GCC 0x02000000
  35. #define GLM_COMPILER_GCC30 0x02000010
  36. #define GLM_COMPILER_GCC31 0x02000020
  37. #define GLM_COMPILER_GCC32 0x02000030
  38. #define GLM_COMPILER_GCC33 0x02000040
  39. #define GLM_COMPILER_GCC34 0x02000050
  40. #define GLM_COMPILER_GCC35 0x02000060
  41. #define GLM_COMPILER_GCC40 0x02000070
  42. #define GLM_COMPILER_GCC41 0x02000080
  43. #define GLM_COMPILER_GCC42 0x02000090
  44. #define GLM_COMPILER_GCC43 0x020000A0
  45. #define GLM_COMPILER_GCC44 0x020000B0
  46. #define GLM_COMPILER_GCC45 0x020000C0
  47. #define GLM_COMPILER_GCC46 0x020000D0
  48. #define GLM_COMPILER_GCC47 0x020000E0
  49. #define GLM_COMPILER_GCC48 0x020000F0
  50. #define GLM_COMPILER_GCC49 0x02000100
  51. #define GLM_COMPILER_GCC50 0x02000200
  52. // G++ command line to display defined
  53. // echo "" | g++ -E -dM -x c++ - | sort
  54. // Borland C++ defines. How to identify BC?
  55. #define GLM_COMPILER_BC 0x03000000
  56. #define GLM_COMPILER_BCB4 0x03000100
  57. #define GLM_COMPILER_BCB5 0x03000200
  58. #define GLM_COMPILER_BCB6 0x03000300
  59. //#define GLM_COMPILER_BCBX 0x03000400 // What's the version value?
  60. #define GLM_COMPILER_BCB2009 0x03000500
  61. #define GLM_MODEL_32 0x00000010
  62. #define GLM_MODEL_64 0x00000020
  63. // CodeWarrior
  64. #define GLM_COMPILER_CODEWARRIOR 0x04000000
  65. // Force generic C++ compiler
  66. #ifdef GLM_FORCE_COMPILER_UNKNOWN
  67. # define GLM_COMPILER GLM_COMPILER_UNKNOWN
  68. // Visual C++
  69. #elif defined(_MSC_VER)
  70. # if _MSC_VER == 900
  71. # define GLM_COMPILER GLM_COMPILER_VC2
  72. # elif _MSC_VER == 1000
  73. # define GLM_COMPILER GLM_COMPILER_VC4
  74. # elif _MSC_VER == 1100
  75. # define GLM_COMPILER GLM_COMPILER_VC5
  76. # elif _MSC_VER == 1200
  77. # define GLM_COMPILER GLM_COMPILER_VC6
  78. # elif _MSC_VER == 1300
  79. # define GLM_COMPILER GLM_COMPILER_VC2002
  80. # elif _MSC_VER == 1310
  81. # define GLM_COMPILER GLM_COMPILER_VC2003
  82. # elif _MSC_VER == 1400
  83. # define GLM_COMPILER GLM_COMPILER_VC2005
  84. # elif _MSC_VER == 1500
  85. # define GLM_COMPILER GLM_COMPILER_VC2008
  86. # elif _MSC_VER == 1600
  87. # define GLM_COMPILER GLM_COMPILER_VC2010
  88. # else//_MSC_VER
  89. # define GLM_COMPILER GLM_COMPILER_VC
  90. # endif//_MSC_VER
  91. // G++
  92. #elif defined(__GNUC__)
  93. # if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2)
  94. # define GLM_COMPILER GLM_COMPILER_GCC32
  95. # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 3)
  96. # define GLM_COMPILER GLM_COMPILER_GCC33
  97. # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 4)
  98. # define GLM_COMPILER GLM_COMPILER_GCC34
  99. # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 5)
  100. # define GLM_COMPILER GLM_COMPILER_GCC35
  101. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 0)
  102. # define GLM_COMPILER GLM_COMPILER_GCC40
  103. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 1)
  104. # define GLM_COMPILER GLM_COMPILER_GCC41
  105. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
  106. # define GLM_COMPILER GLM_COMPILER_GCC42
  107. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
  108. # define GLM_COMPILER GLM_COMPILER_GCC43
  109. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
  110. # define GLM_COMPILER GLM_COMPILER_GCC44
  111. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 5)
  112. # define GLM_COMPILER GLM_COMPILER_GCC45
  113. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
  114. # define GLM_COMPILER GLM_COMPILER_GCC46
  115. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
  116. # define GLM_COMPILER GLM_COMPILER_GCC47
  117. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
  118. # define GLM_COMPILER GLM_COMPILER_GCC48
  119. # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 9)
  120. # define GLM_COMPILER GLM_COMPILER_GCC49
  121. # elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 0)
  122. # define GLM_COMPILER GLM_COMPILER_GCC50
  123. # else
  124. # define GLM_COMPILER GLM_COMPILER_GCC
  125. # endif
  126. // Borland C++
  127. #elif defined(_BORLANDC_)
  128. # if defined(VER125)
  129. # define GLM_COMPILER GLM_COMPILER_BCB4
  130. # elif defined(VER130)
  131. # define GLM_COMPILER GLM_COMPILER_BCB5
  132. # elif defined(VER140)
  133. # define GLM_COMPILER GLM_COMPILER_BCB6
  134. # elif defined(VER200)
  135. # define GLM_COMPILER GLM_COMPILER_BCB2009
  136. # else
  137. # define GLM_COMPILER GLM_COMPILER_BC
  138. # endif
  139. // Codewarrior
  140. #elif defined(__MWERKS__)
  141. # define GLM_COMPILER GLM_COMPILER_CODEWARRIOR
  142. #else
  143. # define GLM_COMPILER GLM_COMPILER_UNKNOWN
  144. #endif
  145. #ifndef GLM_COMPILER
  146. #error "GLM_COMPILER undefined, your compiler may not be supported by GLM. Add #define GLM_COMPILER 0 to ignore this message."
  147. #endif//GLM_COMPILER
  148. // Report compiler detection
  149. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPILER_DISPLAYED))
  150. # define GLM_MESSAGE_COMPILER_DISPLAYED
  151. # if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC)
  152. # pragma message("GLM: Visual C++ compiler detected")
  153. # elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_GCC)
  154. # pragma message("GLM: GCC compiler detected")
  155. # elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_BC)
  156. # pragma message("GLM: Borland compiler detected but not supported")
  157. # elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_CODEWARRIOR)
  158. # pragma message("GLM: Codewarrior compiler detected but not supported")
  159. # else
  160. # pragma message("GLM: Compiler not detected")
  161. # endif
  162. #endif//GLM_MESSAGE
  163. /////////////////
  164. // Build model //
  165. #if(GLM_COMPILER & GLM_COMPILER_VC)
  166. # if defined(_M_X64)
  167. # define GLM_MODEL GLM_MODEL_64
  168. # else
  169. # define GLM_MODEL GLM_MODEL_32
  170. # endif//_M_X64
  171. #elif(GLM_COMPILER & GLM_COMPILER_GCC)
  172. # if(defined(__WORDSIZE) && (__WORDSIZE == 64)) || defined(__arch64__) || defined(__LP64__) || defined(__x86_64__)
  173. # define GLM_MODEL GLM_MODEL_64
  174. # else
  175. # define GLM_MODEL GLM_MODEL_32
  176. # endif//
  177. #else
  178. # define GLM_MODEL GLM_MODEL_32
  179. #endif//
  180. #if(!defined(GLM_MODEL) && GLM_COMPILER != 0)
  181. #error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
  182. #endif//GLM_MODEL
  183. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_MODEL_DISPLAYED))
  184. # define GLM_MESSAGE_MODEL_DISPLAYED
  185. # if(GLM_MODEL == GLM_MODEL_64)
  186. # pragma message("GLM: 64 bits model")
  187. # elif(GLM_MODEL == GLM_MODEL_32)
  188. # pragma message("GLM: 32 bits model")
  189. # endif//GLM_MODEL
  190. #endif//GLM_MESSAGE
  191. /////////////////
  192. // C++ Version //
  193. // User defines: GLM_FORCE_CXX98
  194. #define GLM_LANG_CXX 0
  195. #define GLM_LANG_CXX98 1
  196. #define GLM_LANG_CXX0X 2
  197. #define GLM_LANG_CXXMS 3
  198. #define GLM_LANG_CXXGNU 4
  199. #if(defined(GLM_FORCE_CXX98))
  200. # define GLM_LANG GLM_LANG_CXX98
  201. #elif(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && defined(__GXX_EXPERIMENTAL_CXX0X__)) // -std=c++0x or -std=gnu++0x
  202. # define GLM_LANG GLM_LANG_CXX0X
  203. #elif(GLM_COMPILER == GLM_COMPILER_VC2010) //_MSC_EXTENSIONS for MS language extensions
  204. # define GLM_LANG GLM_LANG_CXX0X
  205. #elif(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && defined(__STRICT_ANSI__))
  206. # define GLM_LANG GLM_LANG_CXX98
  207. #elif(((GLM_COMPILER & GLM_COMPILER_VC) == GLM_COMPILER_VC) && !defined(_MSC_EXTENSIONS))
  208. # define GLM_LANG GLM_LANG_CXX98
  209. #else
  210. # define GLM_LANG GLM_LANG_CXX
  211. #endif
  212. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED))
  213. # define GLM_MESSAGE_LANG_DISPLAYED
  214. # if(GLM_LANG == GLM_LANG_CXX98)
  215. # pragma message("GLM: C++98")
  216. # elif(GLM_LANG == GLM_LANG_CXX0X)
  217. # pragma message("GLM: C++0x")
  218. # endif//GLM_MODEL
  219. #endif//GLM_MESSAGE
  220. /////////////////
  221. // Platform
  222. // User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_AVX
  223. #define GLM_ARCH_PURE 0x0000 //(0x0000)
  224. #define GLM_ARCH_SSE2 0x0001 //(0x0001)
  225. #define GLM_ARCH_SSE3 0x0003 //(0x0002 | GLM_ARCH_SSE2)
  226. #define GLM_ARCH_AVX 0x0007 //(0x0004 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
  227. #if(defined(GLM_FORCE_PURE))
  228. # define GLM_ARCH GLM_ARCH_PURE
  229. #elif(defined(GLM_FORCE_AVX))
  230. # define GLM_ARCH GLM_ARCH_AVX
  231. #elif(defined(GLM_FORCE_SSE3))
  232. # define GLM_ARCH GLM_ARCH_SSE3
  233. #elif(defined(GLM_FORCE_SSE2))
  234. # define GLM_ARCH GLM_ARCH_SSE2
  235. #elif((GLM_COMPILER & GLM_COMPILER_VC) && (defined(_M_IX86) || defined(_M_X64)))
  236. # if(defined(_M_CEE_PURE))
  237. # define GLM_ARCH GLM_ARCH_PURE
  238. # elif(GLM_COMPILER >= GLM_COMPILER_VC2010)
  239. # if(_MSC_FULL_VER >= 160031118) //160031118: VC2010 SP1 beta full version
  240. # define GLM_ARCH GLM_ARCH_AVX //GLM_ARCH_AVX (Require SP1)
  241. # else
  242. # define GLM_ARCH GLM_ARCH_SSE3
  243. # endif
  244. # elif(GLM_COMPILER >= GLM_COMPILER_VC2008)
  245. # define GLM_ARCH GLM_ARCH_SSE3
  246. # elif(GLM_COMPILER >= GLM_COMPILER_VC2005)
  247. # define GLM_ARCH GLM_ARCH_SSE2
  248. # else
  249. # define GLM_ARCH GLM_ARCH_PURE
  250. # endif
  251. #elif((GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__)))
  252. # if(defined(__AVX__))
  253. # define GLM_ARCH GLM_ARCH_AVX
  254. # elif(defined(__SSE3__))
  255. # define GLM_ARCH GLM_ARCH_SSE3
  256. # elif(defined(__SSE2__))
  257. # define GLM_ARCH GLM_ARCH_SSE2
  258. # else
  259. # define GLM_ARCH GLM_ARCH_PURE
  260. # endif
  261. #else
  262. # define GLM_ARCH GLM_ARCH_PURE
  263. #endif
  264. #if(GLM_ARCH != GLM_ARCH_PURE)
  265. #if((GLM_ARCH & GLM_ARCH_AVX) == GLM_ARCH_AVX)
  266. # include <immintrin.h>
  267. #endif//GLM_ARCH
  268. #if((GLM_ARCH & GLM_ARCH_SSE3) == GLM_ARCH_SSE3)
  269. # include <pmmintrin.h>
  270. #endif//GLM_ARCH
  271. #if((GLM_ARCH & GLM_ARCH_SSE2) == GLM_ARCH_SSE2)
  272. # include <emmintrin.h>
  273. #endif//GLM_ARCH
  274. #endif//(GLM_ARCH != GLM_ARCH_PURE)
  275. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_ARCH_DISPLAYED))
  276. # define GLM_MESSAGE_ARCH_DISPLAYED
  277. # if(GLM_ARCH == GLM_ARCH_PURE)
  278. # pragma message("GLM: Platform independent")
  279. # elif(GLM_ARCH == GLM_ARCH_SSE2)
  280. # pragma message("GLM: SSE2 build platform")
  281. # elif(GLM_ARCH == GLM_ARCH_SSE3)
  282. # pragma message("GLM: SSE3 build platform")
  283. # elif(GLM_ARCH == GLM_ARCH_AVX)
  284. # pragma message("GLM: AVX build platform")
  285. # endif//GLM_ARCH
  286. #endif//GLM_MESSAGE
  287. ///////////////////////////////////////////////////////////////////////////////////////////////////
  288. // Components
  289. //#define GLM_FORCE_ONLY_XYZW
  290. #define GLM_COMPONENT_GLSL_NAMES 0
  291. #define GLM_COMPONENT_ONLY_XYZW 1 // To disable multiple vector component names access.
  292. #define GLM_COMPONENT_MS_EXT 2 // To use anonymous union to provide multiple component names access for class valType. Visual C++ only.
  293. #ifndef GLM_FORCE_ONLY_XYZW
  294. # if((GLM_COMPILER & GLM_COMPILER_VC) && defined(_MSC_EXTENSIONS))
  295. # define GLM_COMPONENT GLM_COMPONENT_MS_EXT
  296. # else
  297. # define GLM_COMPONENT GLM_COMPONENT_GLSL_NAMES
  298. # endif
  299. #else
  300. # define GLM_COMPONENT GLM_COMPONENT_ONLY_XYZW
  301. #endif
  302. #if((GLM_COMPONENT == GLM_COMPONENT_MS_EXT) && !(GLM_COMPILER & GLM_COMPILER_VC))
  303. # error "GLM_COMPONENT value is GLM_COMPONENT_MS_EXT but this is not allowed with the current compiler."
  304. #endif
  305. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPONENT_DISPLAYED))
  306. # define GLM_MESSAGE_COMPONENT_DISPLAYED
  307. # if(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
  308. # pragma message("GLM: GLSL multiple vector component names")
  309. # elif(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
  310. # pragma message("GLM: x,y,z,w vector component names only")
  311. # elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
  312. # pragma message("GLM: Multiple vector component names through Visual C++ language extensions")
  313. # else
  314. # error "GLM_COMPONENT value unknown"
  315. # endif//GLM_MESSAGE_COMPONENT_DISPLAYED
  316. #endif//GLM_MESSAGE
  317. ///////////////////////////////////////////////////////////////////////////////////////////////////
  318. // Static assert
  319. #if(GLM_LANG == GLM_LANG_CXX0X)
  320. # define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
  321. #elif(defined(BOOST_STATIC_ASSERT))
  322. # define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)
  323. #elif(GLM_COMPILER & GLM_COMPILER_VC)
  324. # define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
  325. #else
  326. # define GLM_STATIC_ASSERT(x, message)
  327. #endif//GLM_LANG
  328. ///////////////////////////////////////////////////////////////////////////////////////////////////
  329. // inline
  330. // User defines: GLM_FORCE_INLINE
  331. #if(defined(GLM_FORCE_INLINE))
  332. # if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
  333. # define GLM_INLINE __forceinline
  334. # elif((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
  335. # define GLM_INLINE __attribute__((always_inline))
  336. # else
  337. # define GLM_INLINE inline
  338. # endif//GLM_COMPILER
  339. #else
  340. # define GLM_INLINE inline
  341. #endif//defined(GLM_FORCE_INLINE)
  342. ///////////////////////////////////////////////////////////////////////////////////////////////////
  343. // Swizzle operators
  344. // User defines: GLM_SWIZZLE_XYZW GLM_SWIZZLE_RGBA GLM_SWIZZLE_STQP GLM_SWIZZLE
  345. #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED))
  346. # define GLM_MESSAGE_SWIZZLE_DISPLAYED
  347. # if(defined(GLM_SWIZZLE))
  348. # pragma message("GLM: Full swizzling operator enabled")
  349. # elif(!defined(GLM_SWIZZLE_XYZW) && !defined(GLM_SWIZZLE_RGBA) && !defined(GLM_SWIZZLE_STQP) && !defined(GLM_SWIZZLE))
  350. # pragma message("GLM: No swizzling operator enabled")
  351. # else
  352. # pragma message("GLM: Partial swizzling operator enabled")
  353. # endif
  354. #endif//GLM_MESSAGE
  355. ///////////////////////////////////////////////////////////////////////////////////////////////////
  356. // Precision
  357. #define GLM_PRECISION_NONE 0x00000000
  358. #define GLM_PRECISION_LOWP_FLOAT 0x00000011
  359. #define GLM_PRECISION_MEDIUMP_FLOAT 0x00000012
  360. #define GLM_PRECISION_HIGHP_FLOAT 0x00000013
  361. #define GLM_PRECISION_LOWP_INT 0x00001100
  362. #define GLM_PRECISION_MEDIUMP_INT 0x00001200
  363. #define GLM_PRECISION_HIGHP_INT 0x00001300
  364. #define GLM_PRECISION_LOWP_UINT 0x00110000
  365. #define GLM_PRECISION_MEDIUMP_UINT 0x00120000
  366. #define GLM_PRECISION_HIGHP_UINT 0x00130000
  367. #endif//glm_setup