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.
 
 
 

76 line
2.1 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #include <lol/engine-internal.h>
  11. namespace lol {
  12. #define LOL_VEC_2_CONST(T, name, a, b) \
  13. template<> \
  14. vec_t<T,2> const vec_t<T,2>::name = vec_t<T,2>((T)a, (T)b);
  15. #define LOL_VEC_3_CONST(T, name, a, b, c) \
  16. template<> \
  17. vec_t<T,3> const vec_t<T,3>::name = vec_t<T,3>((T)a, (T)b, (T)c);
  18. #define LOL_VEC_4_CONST(T, name, a, b, c, d) \
  19. template<> \
  20. vec_t<T,4> const vec_t<T,4>::name = vec_t<T,4>((T)a, (T)b, (T)c, (T)d);
  21. #define LOL_MAT_CONST(T, name, a) \
  22. template<> \
  23. mat_t<T,2,2> const mat_t<T,2,2>::name = mat_t<T,2,2>((T)a); \
  24. \
  25. template<> \
  26. mat_t<T,3,3> const mat_t<T,3,3>::name = mat_t<T,3,3>((T)a); \
  27. \
  28. template<> \
  29. mat_t<T,4,4> const mat_t<T,4,4>::name = mat_t<T,4,4>((T)a);
  30. #define LOL_ALL_CONST_INNER(T) \
  31. LOL_VEC_2_CONST(T, zero, 0, 0) \
  32. LOL_VEC_2_CONST(T, axis_x, 1, 0) \
  33. LOL_VEC_2_CONST(T, axis_y, 0, 1) \
  34. \
  35. LOL_VEC_3_CONST(T, zero, 0, 0, 0) \
  36. LOL_VEC_3_CONST(T, axis_x, 1, 0, 0) \
  37. LOL_VEC_3_CONST(T, axis_y, 0, 1, 0) \
  38. LOL_VEC_3_CONST(T, axis_z, 0, 0, 1) \
  39. \
  40. LOL_VEC_4_CONST(T, zero, 0, 0, 0, 0) \
  41. LOL_VEC_4_CONST(T, axis_x, 1, 0, 0, 0) \
  42. LOL_VEC_4_CONST(T, axis_y, 0, 1, 0, 0) \
  43. LOL_VEC_4_CONST(T, axis_z, 0, 0, 1, 0) \
  44. LOL_VEC_4_CONST(T, axis_w, 0, 0, 0, 1) \
  45. \
  46. LOL_MAT_CONST(T, identity, 1)
  47. #if LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS
  48. LOL_ALL_CONST_INNER(half)
  49. #endif
  50. LOL_ALL_CONST_INNER(float)
  51. LOL_ALL_CONST_INNER(double)
  52. LOL_ALL_CONST_INNER(ldouble)
  53. #if LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS
  54. LOL_ALL_CONST_INNER(real)
  55. #endif
  56. LOL_ALL_CONST_INNER(int8_t)
  57. LOL_ALL_CONST_INNER(uint8_t)
  58. LOL_ALL_CONST_INNER(int16_t)
  59. LOL_ALL_CONST_INNER(uint16_t)
  60. LOL_ALL_CONST_INNER(int32_t)
  61. LOL_ALL_CONST_INNER(uint32_t)
  62. LOL_ALL_CONST_INNER(int64_t)
  63. LOL_ALL_CONST_INNER(uint64_t)
  64. }; /* namespace lol */