76 lines
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. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include "core.h"
  14. namespace lol {
  15. #define LOL_VEC_2_CONST(type, name, a, b) \
  16. template<> \
  17. Vec2<type> const Vec2<type>::name = Vec2<type>((type)a, (type)b);
  18. #define LOL_VEC_3_CONST(type, name, a, b, c) \
  19. template<> \
  20. Vec3<type> const Vec3<type>::name = Vec3<type>((type)a, (type)b, (type)c);
  21. #define LOL_VEC_4_CONST(type, name, a, b, c, d) \
  22. template<> \
  23. Vec4<type> const Vec4<type>::name = Vec4<type>((type)a, (type)b, (type)c, (type)d);
  24. #define LOL_MAT_CONST(type, name, a) \
  25. template<> \
  26. Mat2<type> const Mat2<type>::name = Mat2<type>((type)a); \
  27. \
  28. template<> \
  29. Mat3<type> const Mat3<type>::name = Mat3<type>((type)a); \
  30. \
  31. template<> \
  32. Mat4<type> const Mat4<type>::name = Mat4<type>((type)a);
  33. #define LOL_ALL_CONST_INNER(type) \
  34. LOL_VEC_2_CONST(type, zero, 0, 0) \
  35. LOL_VEC_2_CONST(type, axis_x, 1, 0) \
  36. LOL_VEC_2_CONST(type, axis_y, 0, 1) \
  37. \
  38. LOL_VEC_3_CONST(type, zero, 0, 0, 0) \
  39. LOL_VEC_3_CONST(type, axis_x, 1, 0, 0) \
  40. LOL_VEC_3_CONST(type, axis_y, 0, 1, 0) \
  41. LOL_VEC_3_CONST(type, axis_z, 0, 0, 1) \
  42. \
  43. LOL_VEC_4_CONST(type, zero, 0, 0, 0, 0) \
  44. LOL_VEC_4_CONST(type, axis_x, 1, 0, 0, 0) \
  45. LOL_VEC_4_CONST(type, axis_y, 0, 1, 0, 0) \
  46. LOL_VEC_4_CONST(type, axis_z, 0, 0, 1, 0) \
  47. LOL_VEC_4_CONST(type, axis_w, 0, 0, 0, 1) \
  48. \
  49. LOL_MAT_CONST(type, identity, 1)
  50. LOL_ALL_CONST_INNER(half)
  51. LOL_ALL_CONST_INNER(float)
  52. LOL_ALL_CONST_INNER(double)
  53. LOL_ALL_CONST_INNER(ldouble)
  54. LOL_ALL_CONST_INNER(real)
  55. LOL_ALL_CONST_INNER(int8_t)
  56. LOL_ALL_CONST_INNER(uint8_t)
  57. LOL_ALL_CONST_INNER(int16_t)
  58. LOL_ALL_CONST_INNER(uint16_t)
  59. LOL_ALL_CONST_INNER(int32_t)
  60. LOL_ALL_CONST_INNER(uint32_t)
  61. LOL_ALL_CONST_INNER(int64_t)
  62. LOL_ALL_CONST_INNER(uint64_t)
  63. }; /* namespace lol */