Platformer in OpenGL
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.

166 lines
4.3 KiB

5 years ago
  1. #include <glm/gtc/constants.hpp>
  2. #include <glm/ext/scalar_relational.hpp>
  3. #include <glm/ext/vector_relational.hpp>
  4. #include <glm/ext/vector_double1.hpp>
  5. #include <glm/ext/vector_double1_precision.hpp>
  6. #include <glm/ext/vector_double2.hpp>
  7. #include <glm/ext/vector_double3.hpp>
  8. #include <glm/ext/vector_double4.hpp>
  9. #include <glm/ext/vector_float1.hpp>
  10. #include <glm/ext/vector_float1_precision.hpp>
  11. #include <glm/ext/vector_float2.hpp>
  12. #include <glm/ext/vector_float3.hpp>
  13. #include <glm/ext/vector_float4.hpp>
  14. template <typename genType>
  15. static int test_operators()
  16. {
  17. typedef typename genType::value_type valType;
  18. int Error = 0;
  19. {
  20. genType const A(1);
  21. genType const B(1);
  22. genType const C = A + B;
  23. Error += glm::all(glm::equal(C, genType(2), glm::epsilon<valType>())) ? 0 : 1;
  24. genType const D = A - B;
  25. Error += glm::all(glm::equal(D, genType(0), glm::epsilon<valType>())) ? 0 : 1;
  26. genType const E = A * B;
  27. Error += glm::all(glm::equal(E, genType(1), glm::epsilon<valType>())) ? 0 : 1;
  28. genType const F = A / B;
  29. Error += glm::all(glm::equal(F, genType(1), glm::epsilon<valType>())) ? 0 : 1;
  30. }
  31. return Error;
  32. }
  33. template <typename genType>
  34. static int test_ctor()
  35. {
  36. typedef typename genType::value_type T;
  37. int Error = 0;
  38. glm::vec<1, T> const A = genType(1);
  39. glm::vec<1, T> const E(genType(1));
  40. Error += glm::all(glm::equal(A, E, glm::epsilon<T>())) ? 0 : 1;
  41. glm::vec<1, T> const F(E);
  42. Error += glm::all(glm::equal(A, F, glm::epsilon<T>())) ? 0 : 1;
  43. genType const B = genType(1);
  44. genType const G(glm::vec<2, T>(1));
  45. Error += glm::all(glm::equal(B, G, glm::epsilon<T>())) ? 0 : 1;
  46. genType const H(glm::vec<3, T>(1));
  47. Error += glm::all(glm::equal(B, H, glm::epsilon<T>())) ? 0 : 1;
  48. genType const I(glm::vec<4, T>(1));
  49. Error += glm::all(glm::equal(B, I, glm::epsilon<T>())) ? 0 : 1;
  50. return Error;
  51. }
  52. template <typename genType>
  53. static int test_size()
  54. {
  55. typedef typename genType::value_type T;
  56. int Error = 0;
  57. Error += sizeof(glm::vec<1, T>) == sizeof(genType) ? 0 : 1;
  58. Error += genType().length() == 1 ? 0 : 1;
  59. Error += genType::length() == 1 ? 0 : 1;
  60. return Error;
  61. }
  62. template <typename genType>
  63. static int test_relational()
  64. {
  65. typedef typename genType::value_type valType;
  66. int Error = 0;
  67. genType const A(1);
  68. genType const B(1);
  69. genType const C(0);
  70. Error += all(equal(A, B, glm::epsilon<valType>())) ? 0 : 1;
  71. Error += any(notEqual(A, C, glm::epsilon<valType>())) ? 0 : 1;
  72. return Error;
  73. }
  74. template <typename genType>
  75. static int test_constexpr()
  76. {
  77. # if GLM_CONFIG_CONSTEXP == GLM_ENABLE
  78. static_assert(genType::length() == 1, "GLM: Failed constexpr");
  79. # endif
  80. return 0;
  81. }
  82. int main()
  83. {
  84. int Error = 0;
  85. Error += test_operators<glm::dvec1>();
  86. Error += test_operators<glm::lowp_dvec1>();
  87. Error += test_operators<glm::mediump_dvec1>();
  88. Error += test_operators<glm::highp_dvec1>();
  89. Error += test_ctor<glm::dvec1>();
  90. Error += test_ctor<glm::lowp_dvec1>();
  91. Error += test_ctor<glm::mediump_dvec1>();
  92. Error += test_ctor<glm::highp_dvec1>();
  93. Error += test_size<glm::dvec1>();
  94. Error += test_size<glm::lowp_dvec1>();
  95. Error += test_size<glm::mediump_dvec1>();
  96. Error += test_size<glm::highp_dvec1>();
  97. Error += test_relational<glm::dvec1>();
  98. Error += test_relational<glm::lowp_dvec1>();
  99. Error += test_relational<glm::mediump_dvec1>();
  100. Error += test_relational<glm::highp_dvec1>();
  101. Error += test_constexpr<glm::dvec1>();
  102. Error += test_constexpr<glm::lowp_dvec1>();
  103. Error += test_constexpr<glm::mediump_dvec1>();
  104. Error += test_constexpr<glm::highp_dvec1>();
  105. Error += test_operators<glm::vec1>();
  106. Error += test_operators<glm::lowp_vec1>();
  107. Error += test_operators<glm::mediump_vec1>();
  108. Error += test_operators<glm::highp_vec1>();
  109. Error += test_ctor<glm::vec1>();
  110. Error += test_ctor<glm::lowp_vec1>();
  111. Error += test_ctor<glm::mediump_vec1>();
  112. Error += test_ctor<glm::highp_vec1>();
  113. Error += test_size<glm::vec1>();
  114. Error += test_size<glm::lowp_vec1>();
  115. Error += test_size<glm::mediump_vec1>();
  116. Error += test_size<glm::highp_vec1>();
  117. Error += test_relational<glm::vec1>();
  118. Error += test_relational<glm::lowp_vec1>();
  119. Error += test_relational<glm::mediump_vec1>();
  120. Error += test_relational<glm::highp_vec1>();
  121. Error += test_constexpr<glm::vec1>();
  122. Error += test_constexpr<glm::lowp_vec1>();
  123. Error += test_constexpr<glm::mediump_vec1>();
  124. Error += test_constexpr<glm::highp_vec1>();
  125. return Error;
  126. }