type_ptr.hpp 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2009-05-06
  5. // Updated : 2010-04-30
  6. // Licence : This source is under MIT License
  7. // File : glm/gtc/type_ptr.hpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. // Dependency:
  10. // - GLM core
  11. ///////////////////////////////////////////////////////////////////////////////////////////////////
  12. #ifndef glm_gtc_type_ptr
  13. #define glm_gtc_type_ptr
  14. // Dependency:
  15. #include "../glm.hpp"
  16. #if(defined(GLM_MESSAGES) && !defined(glm_ext))
  17. # pragma message("GLM: GLM_GTC_type_ptr extension included")
  18. #endif
  19. namespace glm
  20. {
  21. namespace test{
  22. void main_gtc_type_ptr();
  23. }//namespace test
  24. namespace gtc{
  25. //! GLM_GTC_type_ptr extension: Get access to vectors & matrices value type address.
  26. namespace type_ptr{
  27. /// \addtogroup gtc_type_ptr
  28. ///@{
  29. //! Get the const address of the vector content.
  30. //! From GLM_GTC_type_ptr extension.
  31. template<typename T>
  32. inline T const * value_ptr
  33. (
  34. detail::tvec2<T> const & vec
  35. )
  36. {
  37. return &(vec.x);
  38. }
  39. //! Get the address of the vector content.
  40. //! From GLM_GTC_type_ptr extension.
  41. template<typename T>
  42. inline T * value_ptr
  43. (
  44. detail::tvec2<T> & vec
  45. )
  46. {
  47. return &(vec.x);
  48. }
  49. //! Get the const address of the vector content.
  50. //! From GLM_GTC_type_ptr extension.
  51. template<typename T>
  52. inline T const * value_ptr
  53. (
  54. detail::tvec3<T> const & vec
  55. )
  56. {
  57. return &(vec.x);
  58. }
  59. //! Get the address of the vector content.
  60. //! From GLM_GTC_type_ptr extension.
  61. template<typename T>
  62. inline T * value_ptr
  63. (
  64. detail::tvec3<T> & vec
  65. )
  66. {
  67. return &(vec.x);
  68. }
  69. //! Get the const address of the vector content.
  70. //! From GLM_GTC_type_ptr extension.
  71. template<typename T>
  72. inline T const * value_ptr
  73. (
  74. detail::tvec4<T> const & vec
  75. )
  76. {
  77. return &(vec.x);
  78. }
  79. //! Get the address of the vector content.
  80. //! From GLM_GTC_type_ptr extension.
  81. template<typename T>
  82. inline T * value_ptr
  83. (
  84. detail::tvec4<T> & vec
  85. )
  86. {
  87. return &(vec.x);
  88. }
  89. //! Get the const address of the matrix content.
  90. //! From GLM_GTC_type_ptr extension.
  91. template<typename T>
  92. inline T const * value_ptr
  93. (
  94. detail::tmat2x2<T> const & mat
  95. )
  96. {
  97. return &(mat[0].x);
  98. }
  99. //! Get the address of the matrix content.
  100. //! From GLM_GTC_type_ptr extension.
  101. template<typename T>
  102. inline T * value_ptr
  103. (
  104. detail::tmat2x2<T> & mat
  105. )
  106. {
  107. return &(mat[0].x);
  108. }
  109. //! Get the const address of the matrix content.
  110. //! From GLM_GTC_type_ptr extension.
  111. template<typename T>
  112. inline T const * value_ptr
  113. (
  114. detail::tmat3x3<T> const & mat
  115. )
  116. {
  117. return &(mat[0].x);
  118. }
  119. //! Get the address of the matrix content.
  120. //! From GLM_GTC_type_ptr extension.
  121. template<typename T>
  122. inline T * value_ptr
  123. (
  124. detail::tmat3x3<T> & mat
  125. )
  126. {
  127. return &(mat[0].x);
  128. }
  129. //! Get the const address of the matrix content.
  130. //! From GLM_GTC_type_ptr extension.
  131. template<typename T>
  132. inline T const * value_ptr
  133. (
  134. detail::tmat4x4<T> const & mat
  135. )
  136. {
  137. return &(mat[0].x);
  138. }
  139. //! Get the address of the matrix content.
  140. //! From GLM_GTC_type_ptr extension.
  141. template<typename T>
  142. inline T * value_ptr
  143. (
  144. detail::tmat4x4<T> & mat
  145. )
  146. {
  147. return &(mat[0].x);
  148. }
  149. //! Get the const address of the matrix content.
  150. //! From GLM_GTC_type_ptr extension.
  151. template<typename T>
  152. inline T const * value_ptr
  153. (
  154. detail::tmat2x3<T> const & mat
  155. )
  156. {
  157. return &(mat[0].x);
  158. }
  159. //! Get the address of the matrix content.
  160. //! From GLM_GTC_type_ptr extension.
  161. template<typename T>
  162. inline T * value_ptr
  163. (
  164. detail::tmat2x3<T> & mat
  165. )
  166. {
  167. return &(mat[0].x);
  168. }
  169. //! Get the const address of the matrix content.
  170. //! From GLM_GTC_type_ptr extension.
  171. template<typename T>
  172. inline T const * value_ptr
  173. (
  174. detail::tmat3x2<T> const & mat
  175. )
  176. {
  177. return &(mat[0].x);
  178. }
  179. //! Get the address of the matrix content.
  180. //! From GLM_GTC_type_ptr extension.
  181. template<typename T>
  182. inline T * value_ptr
  183. (
  184. detail::tmat3x2<T> & mat
  185. )
  186. {
  187. return &(mat[0].x);
  188. }
  189. //! Get the const address of the matrix content.
  190. //! From GLM_GTC_type_ptr extension.
  191. template<typename T>
  192. inline T const * value_ptr
  193. (
  194. detail::tmat2x4<T> const & mat
  195. )
  196. {
  197. return &(mat[0].x);
  198. }
  199. //! Get the address of the matrix content.
  200. //! From GLM_GTC_type_ptr extension.
  201. template<typename T>
  202. inline T * value_ptr
  203. (
  204. detail::tmat2x4<T> & mat
  205. )
  206. {
  207. return &(mat[0].x);
  208. }
  209. //! Get the const address of the matrix content.
  210. //! From GLM_GTC_type_ptr extension.
  211. template<typename T>
  212. inline T const * value_ptr
  213. (
  214. detail::tmat4x2<T> const & mat
  215. )
  216. {
  217. return &(mat[0].x);
  218. }
  219. //! Get the address of the matrix content.
  220. //! From GLM_GTC_type_ptr extension.
  221. template<typename T>
  222. inline T * value_ptr
  223. (
  224. detail::tmat4x2<T> & mat
  225. )
  226. {
  227. return &(mat[0].x);
  228. }
  229. //! Get the const address of the matrix content.
  230. //! From GLM_GTC_type_ptr extension.
  231. template<typename T>
  232. inline T const * value_ptr
  233. (
  234. detail::tmat3x4<T> const & mat
  235. )
  236. {
  237. return &(mat[0].x);
  238. }
  239. //! Get the address of the matrix content.
  240. //! From GLM_GTC_type_ptr extension.
  241. template<typename T>
  242. inline T * value_ptr
  243. (
  244. detail::tmat3x4<T> & mat
  245. )
  246. {
  247. return &(mat[0].x);
  248. }
  249. //! Get the const address of the matrix content.
  250. //! From GLM_GTC_type_ptr extension.
  251. template<typename T>
  252. inline T const * value_ptr
  253. (
  254. detail::tmat4x3<T> const & mat
  255. )
  256. {
  257. return &(mat[0].x);
  258. }
  259. //! Get the address of the matrix content.
  260. //! From GLM_GTC_type_ptr extension.
  261. template<typename T>
  262. inline T * value_ptr(detail::tmat4x3<T> & mat)
  263. {
  264. return &(mat[0].x);
  265. }
  266. //! Build a vector from a pointer.
  267. //! From GLM_GTC_type_ptr extension.
  268. template<typename T>
  269. inline detail::tvec2<T> make_vec2(T const * const ptr)
  270. {
  271. detail::tvec2<T> Result;
  272. memcpy(value_ptr(Result), ptr, sizeof(detail::tvec2<T>));
  273. return Result;
  274. }
  275. //! Build a vector from a pointer.
  276. //! From GLM_GTC_type_ptr extension.
  277. template<typename T>
  278. inline detail::tvec3<T> make_vec3(T const * const ptr)
  279. {
  280. detail::tvec3<T> Result;
  281. memcpy(value_ptr(Result), ptr, sizeof(detail::tvec3<T>));
  282. return Result;
  283. }
  284. //! Build a vector from a pointer.
  285. //! From GLM_GTC_type_ptr extension.
  286. template<typename T>
  287. inline detail::tvec4<T> make_vec4(T const * const ptr)
  288. {
  289. detail::tvec4<T> Result;
  290. memcpy(value_ptr(Result), ptr, sizeof(detail::tvec4<T>));
  291. return Result;
  292. }
  293. //! Build a matrix from a pointer.
  294. //! From GLM_GTC_type_ptr extension.
  295. template<typename T>
  296. inline detail::tmat2x2<T> make_mat2x2(T const * const ptr)
  297. {
  298. detail::tmat2x2<T> Result;
  299. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x2<T>));
  300. return Result;
  301. }
  302. //! Build a matrix from a pointer.
  303. //! From GLM_GTC_type_ptr extension.
  304. template<typename T>
  305. inline detail::tmat2x3<T> make_mat2x3(T const * const ptr)
  306. {
  307. detail::tmat2x3<T> Result;
  308. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x3<T>));
  309. return Result;
  310. }
  311. //! Build a matrix from a pointer.
  312. //! From GLM_GTC_type_ptr extension.
  313. template<typename T>
  314. inline detail::tmat2x4<T> make_mat2x4(T const * const ptr)
  315. {
  316. detail::tmat2x4<T> Result;
  317. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x4<T>));
  318. return Result;
  319. }
  320. //! Build a matrix from a pointer.
  321. //! From GLM_GTC_type_ptr extension.
  322. template<typename T>
  323. inline detail::tmat3x2<T> make_mat3x2(T const * const ptr)
  324. {
  325. detail::tmat3x2<T> Result;
  326. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x2<T>));
  327. return Result;
  328. }
  329. //! Build a matrix from a pointer.
  330. //! From GLM_GTC_type_ptr extension.
  331. template<typename T>
  332. inline detail::tmat3x3<T> make_mat3x3(T const * const ptr)
  333. {
  334. detail::tmat3x3<T> Result;
  335. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x3<T>));
  336. return Result;
  337. }
  338. //! Build a matrix from a pointer.
  339. //! From GLM_GTC_type_ptr extension.
  340. template<typename T>
  341. inline detail::tmat3x4<T> make_mat3x4(T const * const ptr)
  342. {
  343. detail::tmat3x4<T> Result;
  344. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x4<T>));
  345. return Result;
  346. }
  347. //! Build a matrix from a pointer.
  348. //! From GLM_GTC_type_ptr extension.
  349. template<typename T>
  350. inline detail::tmat4x2<T> make_mat4x2(T const * const ptr)
  351. {
  352. detail::tmat4x2<T> Result;
  353. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x2<T>));
  354. return Result;
  355. }
  356. //! Build a matrix from a pointer.
  357. //! From GLM_GTC_type_ptr extension.
  358. template<typename T>
  359. inline detail::tmat4x3<T> make_mat4x3(T const * const ptr)
  360. {
  361. detail::tmat4x3<T> Result;
  362. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x3<T>));
  363. return Result;
  364. }
  365. //! Build a matrix from a pointer.
  366. //! From GLM_GTC_type_ptr extension.
  367. template<typename T>
  368. inline detail::tmat4x4<T> make_mat4x4(T const * const ptr)
  369. {
  370. detail::tmat4x4<T> Result;
  371. memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x4<T>));
  372. return Result;
  373. }
  374. //! Build a matrix from a pointer.
  375. //! From GLM_GTC_type_ptr extension.
  376. template<typename T>
  377. inline detail::tmat2x2<T> make_mat2(T const * const ptr)
  378. {
  379. return make_mat2x2(Result);
  380. }
  381. //! Build a matrix from a pointer.
  382. //! From GLM_GTC_type_ptr extension.
  383. template<typename T>
  384. inline detail::tmat3<T> make_mat3(T const * const ptr)
  385. {
  386. return make_mat3x3(Result);
  387. }
  388. //! Build a matrix from a pointer.
  389. //! From GLM_GTC_type_ptr extension.
  390. template<typename T>
  391. inline detail::tmat4<T> make_mat4(T const * const ptr)
  392. {
  393. return make_mat4x4(Result);
  394. }
  395. ///@}
  396. }//namespace type_ptr
  397. }//namespace gtc
  398. }//namespace glm
  399. #include "type_ptr.inl"
  400. namespace glm{using namespace gtc::type_ptr;}
  401. #endif//glm_gtx_type_ptr