setup.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
  3. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2006-11-13
  5. // Updated : 2010-01-28
  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 90
  14. #define GLM_VERSION_MAJOR 0
  15. #define GLM_VERSION_MINOR 9
  16. #define GLM_VERSION_PATCH 0
  17. #define GLM_VERSION_REVISION 4
  18. ///////////////////////////////////////////////////////////////////////////////////////////////////
  19. // Common values
  20. #define GLM_DISABLE 0x00000000
  21. #define GLM_ENABLE 0x00000001
  22. ///////////////////////////////////////////////////////////////////////////////////////////////////
  23. // Message
  24. #define GLM_MESSAGE_QUIET 0x00000000
  25. #define GLM_MESSAGE_WARNING 0x00000001
  26. #define GLM_MESSAGE_NOTIFICATION 0x00000002
  27. #define GLM_MESSAGE_CORE 0x00000004
  28. #define GLM_MESSAGE_EXTS 0x00000008
  29. #define GLM_MESSAGE_SETUP 0x00000010
  30. #define GLM_MESSAGE_ALL GLM_MESSAGE_WARNING | GLM_MESSAGE_NOTIFICATION | GLM_MESSAGE_CORE | GLM_MESSAGE_EXTS | GLM_MESSAGE_SETUP
  31. //! By default:
  32. // #define GLM_MESSAGE GLM_MESSAGE_QUIET
  33. ///////////////////////////////////////////////////////////////////////////////////////////////////
  34. // Precision
  35. #define GLM_PRECISION_NONE 0x00000000
  36. #define GLM_PRECISION_LOWP_FLOAT 0x00000011
  37. #define GLM_PRECISION_MEDIUMP_FLOAT 0x00000012
  38. #define GLM_PRECISION_HIGHP_FLOAT 0x00000013
  39. #define GLM_PRECISION_LOWP_INT 0x00001100
  40. #define GLM_PRECISION_MEDIUMP_INT 0x00001200
  41. #define GLM_PRECISION_HIGHP_INT 0x00001300
  42. #define GLM_PRECISION_LOWP_UINT 0x00110000
  43. #define GLM_PRECISION_MEDIUMP_UINT 0x00120000
  44. #define GLM_PRECISION_HIGHP_UINT 0x00130000
  45. ///////////////////////////////////////////////////////////////////////////////////////////////////
  46. // Compiler
  47. #define GLM_COMPILER_UNKNOWNED 0x00000000
  48. // Visual C++ defines
  49. #define GLM_COMPILER_VC 0x01000000
  50. #define GLM_COMPILER_VC2005 0x01000010
  51. #define GLM_COMPILER_VC2008 0x01000020
  52. #define GLM_COMPILER_VC2010 0x01000040
  53. // GCC defines
  54. #define GLM_COMPILER_GCC 0x02000000
  55. #define GLM_COMPILER_GCC32 0x02000040
  56. #define GLM_COMPILER_GCC33 0x02000080
  57. #define GLM_COMPILER_GCC34 0x02000100
  58. #define GLM_COMPILER_GCC35 0x02000200
  59. #define GLM_COMPILER_GCC40 0x02000400
  60. #define GLM_COMPILER_GCC41 0x02000800
  61. #define GLM_COMPILER_GCC42 0x02001000
  62. #define GLM_COMPILER_GCC43 0x02002000
  63. #define GLM_COMPILER_GCC44 0x02004000
  64. #define GLM_COMPILER_GCC45 0x02008000
  65. #define GLM_COMPILER_GCC46 0x02010000
  66. #define GLM_COMPILER_GCC47 0x02020000
  67. #define GLM_COMPILER_GCC48 0x02040000
  68. #define GLM_COMPILER_GCC49 0x02080000
  69. #define GLM_COMPILER_GCC50 0x02100000
  70. // Borland C++ defines. How to identify BC?
  71. #define GLM_COMPILER_BC 0x03000000
  72. #define GLM_COMPILER_BCB4 0x03000400
  73. #define GLM_COMPILER_BCB5 0x03000800
  74. #define GLM_COMPILER_BCB6 0x03001000
  75. //#define GLM_COMPILER_BCBX 0x03002000 // What's the version value?
  76. #define GLM_COMPILER_BCB2009 0x03004000
  77. #define GLM_MODEL_32 0x00000010
  78. #define GLM_MODEL_64 0x00000020
  79. #ifndef GLM_COMPILER
  80. // CodeWarrior
  81. #define GLM_COMPILER_CODEWARRIOR 0x04000000
  82. /////////////////
  83. // Visual C++ //
  84. #ifdef _MSC_VER
  85. #if defined(_WIN64)
  86. #define GLM_MODEL GLM_MODEL_64
  87. #else
  88. #define GLM_MODEL GLM_MODEL_32
  89. #endif//_WIN64
  90. #if _MSC_VER == 1400
  91. #define GLM_COMPILER GLM_COMPILER_VC2005
  92. #elif _MSC_VER == 1500
  93. #define GLM_COMPILER GLM_COMPILER_VC2008
  94. #elif _MSC_VER == 1600
  95. #define GLM_COMPILER GLM_COMPILER_VC2010
  96. #else//_MSC_VER
  97. #define GLM_COMPILER GLM_COMPILER_VC
  98. #endif//_MSC_VER
  99. //////////////////
  100. // GCC defines //
  101. #elif defined(__GNUC__)
  102. #if(defined(__WORDSIZE) && (__WORDSIZE == 64)) || defined(__arch64__)
  103. #define GLM_MODEL GLM_MODEL_64
  104. #else
  105. #define GLM_MODEL GLM_MODEL_32
  106. #endif//
  107. #if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2)
  108. #define GLM_COMPILER GLM_COMPILER_GCC32
  109. #elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 3)
  110. #define GLM_COMPILER GLM_COMPILER_GCC33
  111. #elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 4)
  112. #define GLM_COMPILER GLM_COMPILER_GCC34
  113. #elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 5)
  114. #define GLM_COMPILER GLM_COMPILER_GCC35
  115. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 0)
  116. #define GLM_COMPILER GLM_COMPILER_GCC40
  117. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 1)
  118. #define GLM_COMPILER GLM_COMPILER_GCC41
  119. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
  120. #define GLM_COMPILER GLM_COMPILER_GCC42
  121. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
  122. #define GLM_COMPILER GLM_COMPILER_GCC43
  123. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
  124. #define GLM_COMPILER GLM_COMPILER_GCC44
  125. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 5)
  126. #define GLM_COMPILER GLM_COMPILER_GCC45
  127. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
  128. #define GLM_COMPILER GLM_COMPILER_GCC46
  129. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
  130. #define GLM_COMPILER GLM_COMPILER_GCC47
  131. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
  132. #define GLM_COMPILER GLM_COMPILER_GCC48
  133. #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 9)
  134. #define GLM_COMPILER GLM_COMPILER_GCC49
  135. #elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 0)
  136. #define GLM_COMPILER GLM_COMPILER_GCC50
  137. #else
  138. #define GLM_COMPILER GLM_COMPILER_GCC
  139. #endif
  140. #elif defined(_BORLANDC_)
  141. #if defined(VER125)
  142. #define GLM_COMPILER GLM_COMPILER_BCB4
  143. #elif defined(VER130)
  144. #define GLM_COMPILER GLM_COMPILER_BCB5
  145. #elif defined(VER140)
  146. #define GLM_COMPILER GLM_COMPILER_BCB6
  147. #elif defined(VER200)
  148. #define GLM_COMPILER GLM_COMPILER_BCB2009
  149. #else
  150. #define GLM_COMPILER GLM_COMPILER_BC
  151. #endif
  152. #elif defined(__MWERKS__)
  153. #define GLM_COMPILER GLM_COMPILER_CODEWARRIOR
  154. #else
  155. #define GLM_COMPILER GLM_COMPILER_UNKNOWNED
  156. #endif//__GNUC__
  157. #endif//GLM_COMPILER
  158. #ifndef GLM_COMPILER
  159. #error "GLM_COMPILER undefined, your compiler may not be supported by GLM. Add #define GLM_COMPILER 0 to ignore this message."
  160. #endif//GLM_COMPILER
  161. #if(!defined(GLM_MODEL) && GLM_COMPILER != 0)
  162. #error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
  163. #endif//GLM_MODEL
  164. #if(defined(GLM_MESSAGE) && (GLM_MESSAGE & (GLM_MESSAGE_SETUP | GLM_MESSAGE_NOTIFICATION)))
  165. # if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC)
  166. # pragma message("GLM message: Compiled with Visual C++")
  167. # elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_GCC)
  168. # pragma message("GLM message: Compiled with GCC")
  169. # else
  170. # pragma message("GLM warning: Compiler not detected")
  171. # endif
  172. #endif//GLM_MESSAGE
  173. #if(defined(GLM_MESSAGE) && (GLM_MESSAGE & (GLM_MESSAGE_SETUP | GLM_MESSAGE_NOTIFICATION)))
  174. # if(GLM_MODEL == GLM_MODEL_64)
  175. # pragma message("GLM message: 64 bits model")
  176. # elif(GLM_MODEL == GLM_MODEL_32)
  177. # pragma message("GLM message: 32 bits model")
  178. # endif//GLM_MODEL
  179. #endif//GLM_MESSAGE
  180. ///////////////////////////////////////////////////////////////////////////////////////////////////
  181. // Compiler instruction set
  182. #define GLM_INSTRUCTION_SET_NULL 0x00000000 //
  183. #define GLM_INSTRUCTION_SET_PURE 0x00000001 // x86intrin.h
  184. #define GLM_INSTRUCTION_SET_MMX 0x00000002 // mmintrin.h (MMX)
  185. #define GLM_INSTRUCTION_SET_3DNOW 0x00000004 // mm3dnow.h (3DNOW!)
  186. #define GLM_INSTRUCTION_SET_SSE 0x00000008 // xmmintrin.h (SSE + MMX)
  187. #define GLM_INSTRUCTION_SET_SSE2 0x00000010 // emmintrin.h (SSE2 + SSE)
  188. #define GLM_INSTRUCTION_SET_SSE3 0x00000020 // pmmintrin.h (SSE3 + SSE2 + SSE1)
  189. #define GLM_INSTRUCTION_SET_SSSE3 0x00000040 // tmmintrin.h (SSSE3 + SSE3 + SSE2 + SSE1)
  190. #define GLM_INSTRUCTION_SET_POPCNT 0x00000080 // popcntintrin.h
  191. #define GLM_INSTRUCTION_SET_SSE4A 0x00000100 // ammintrin.h (SSE4A + POPCNT + SSE3 + SSE2 + SSE)
  192. #define GLM_INSTRUCTION_SET_SSE4_1 0x00000200 // smmintrin.h (SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE)
  193. #define GLM_INSTRUCTION_SET_SSE4_2 0x00000400 // nmmintrin.h (SSE4_2 + SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE)
  194. #define GLM_INSTRUCTION_SET_AES 0x00000800 // wmmintrin.h (AES + PCLMUL + SSE2 + SSE1)
  195. #define GLM_INSTRUCTION_SET_PCLMUL 0x00001000 // wmmintrin.h (AES + PCLMUL + SSE2 + SSE1)
  196. #define GLM_INSTRUCTION_SET_AVX 0x00002000 // immintrin.h (AES + PCLMUL + SSE4_2 + SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE)
  197. #if(defined(GLM_COMPILER) && (GLM_COMPILER & GLM_COMPILER_GCC))
  198. # define GLM_INSTRUCTION_SET GLM_INSTRUCTION_SET_NULL
  199. #elif(defined(GLM_COMPILER) && (GLM_COMPILER & GLM_COMPILER_VC))
  200. # ifdef _M_CEE_PURE
  201. # define GLM_INSTRUCTION_SET GLM_INSTRUCTION_SET_PURE
  202. # else
  203. # define GLM_INSTRUCTION_SET GLM_INSTRUCTION_SET_NULL
  204. # endif
  205. #else
  206. # define GLM_INSTRUCTION_SET GLM_INSTRUCTION_SET_PURE
  207. #endif
  208. #if(GLM_INSTRUCTION_SET != GLM_INSTRUCTION_SET_NULL)
  209. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_MMX)
  210. # include <mmintrin.h>
  211. # endif
  212. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_3DNOW)
  213. # include <mm3dnow.h>
  214. # endif
  215. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE)
  216. # include <xmmintrin.h>
  217. # endif
  218. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE2)
  219. # include <emmintrin.h>
  220. # endif
  221. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE3)
  222. # include <pmmintrin.h>
  223. # endif
  224. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSSE3)
  225. # include <tmmintrin.h>
  226. # endif
  227. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_POPCNT)
  228. # include <popcntintrin.h>
  229. # endif
  230. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE4A)
  231. # include <ammintrin.h>
  232. # endif
  233. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE4_1)
  234. # include <smmintrin.h>
  235. # endif
  236. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE4_2)
  237. # include <nmmintrin.h>
  238. # endif
  239. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_AES)
  240. # include <wmmintrin.h>
  241. # endif
  242. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_PCLMUL)
  243. # include <wmmintrin.h>
  244. # endif
  245. # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_AVX)
  246. # include <immintrin.h>
  247. # endif
  248. #endif
  249. ///////////////////////////////////////////////////////////////////////////////////////////////////
  250. // Swizzle operators
  251. #define GLM_SWIZZLE_NONE 0x00000000
  252. #define GLM_SWIZZLE_XYZW 0x00000002
  253. #define GLM_SWIZZLE_RGBA 0x00000004
  254. #define GLM_SWIZZLE_STQP 0x00000008
  255. #define GLM_SWIZZLE_FULL (GLM_SWIZZLE_XYZW | GLM_SWIZZLE_RGBA | GLM_SWIZZLE_STQP)
  256. //! By default:
  257. // #define GLM_SWIZZLE GLM_SWIZZLE_NONE
  258. #if(defined(GLM_MESSAGE) && (GLM_MESSAGE & (GLM_MESSAGE_SETUP | GLM_MESSAGE_NOTIFICATION)))
  259. # if !defined(GLM_SWIZZLE)|| (defined(GLM_SWIZZLE) && GLM_SWIZZLE == GLM_SWIZZLE_NONE)
  260. # pragma message("GLM message: No swizzling operator used")
  261. # elif(defined(GLM_SWIZZLE) && GLM_SWIZZLE == GLM_SWIZZLE_FULL)
  262. # pragma message("GLM message: Full swizzling operator support enabled")
  263. # elif(defined(GLM_SWIZZLE) && GLM_SWIZZLE & GLM_SWIZZLE_FULL)
  264. # pragma message("GLM message: Partial swizzling operator support enabled")
  265. # endif//GLM_SWIZZLE
  266. #endif//GLM_MESSAGE
  267. ///////////////////////////////////////////////////////////////////////////////////////////////////
  268. // Use options
  269. // To disable multiple vector component names access.
  270. // GLM_USE_ONLY_XYZW
  271. // To use anonymous union to provide multiple component names access for class valType. Visual C++ only.
  272. // GLM_USE_ANONYMOUS_UNION
  273. #if(defined(GLM_USE_ANONYMOUS_UNION) && !(GLM_COMPILER & GLM_COMPILER_VC))
  274. #error "GLM_USE_ANONYMOUS_UNION is defined to use anonymous union implementation of vector types. Anonymous unions can't be used with GCC."
  275. #endif//GLM_USE_ANONYMOUS_UNION
  276. ///////////////////////////////////////////////////////////////////////////////////////////////////
  277. // Static assert
  278. #if((GLM_COMPILER & GLM_COMPILER_VC && GLM_COMPILER >= GLM_COMPILER_VC2010) || (GLM_COMPILER & GLM_COMPILER_GCC && GLM_COMPILER >= GLM_COMPILER_GCC47))
  279. #define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
  280. #elif(defined(BOOST_STATIC_ASSERT))
  281. #define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)
  282. #else
  283. #define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
  284. #endif//GLM_DEPENDENCE
  285. ///////////////////////////////////////////////////////////////////////////////////////////////////
  286. #endif//glm_setup