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.

149 lines
5.2 KiB

5 years ago
  1. #include <glm/ext/vector_relational.hpp>
  2. #include <glm/ext/vector_float1.hpp>
  3. #include <glm/ext/vector_float1_precision.hpp>
  4. #include <glm/ext/vector_float2.hpp>
  5. #include <glm/ext/vector_float2_precision.hpp>
  6. #include <glm/ext/vector_float3.hpp>
  7. #include <glm/ext/vector_float3_precision.hpp>
  8. #include <glm/ext/vector_float4.hpp>
  9. #include <glm/ext/vector_float4_precision.hpp>
  10. #include <glm/ext/vector_double1.hpp>
  11. #include <glm/ext/vector_double1_precision.hpp>
  12. #include <glm/ext/vector_double2.hpp>
  13. #include <glm/ext/vector_double2_precision.hpp>
  14. #include <glm/ext/vector_double3.hpp>
  15. #include <glm/ext/vector_double3_precision.hpp>
  16. #include <glm/ext/vector_double4.hpp>
  17. #include <glm/ext/vector_double4_precision.hpp>
  18. template <typename vecType>
  19. static int test_equal()
  20. {
  21. typedef typename vecType::value_type valType;
  22. valType const A = static_cast<valType>(1.01f);
  23. valType const B = static_cast<valType>(1.02f);
  24. valType const Epsilon1 = static_cast<valType>(0.1f);
  25. valType const Epsilon2 = static_cast<valType>(0.001f);
  26. int Error = 0;
  27. Error += glm::all(glm::equal(vecType(A), vecType(B), Epsilon1)) ? 0 : 1;
  28. Error += glm::all(glm::equal(vecType(A), vecType(B), vecType(Epsilon1))) ? 0 : 1;
  29. Error += !glm::any(glm::equal(vecType(A), vecType(B), Epsilon2)) ? 0 : 1;
  30. Error += !glm::any(glm::equal(vecType(A), vecType(B), vecType(Epsilon2))) ? 0 : 1;
  31. return Error;
  32. }
  33. template <typename vecType>
  34. static int test_notEqual()
  35. {
  36. typedef typename vecType::value_type valType;
  37. valType const A = static_cast<valType>(1.01f);
  38. valType const B = static_cast<valType>(1.02f);
  39. valType const Epsilon1 = static_cast<valType>(0.1f);
  40. valType const Epsilon2 = static_cast<valType>(0.001f);
  41. int Error = 0;
  42. Error += glm::all(glm::notEqual(vecType(A), vecType(B), Epsilon2)) ? 0 : 1;
  43. Error += glm::all(glm::notEqual(vecType(A), vecType(B), vecType(Epsilon2))) ? 0 : 1;
  44. Error += !glm::any(glm::notEqual(vecType(A), vecType(B), Epsilon1)) ? 0 : 1;
  45. Error += !glm::any(glm::notEqual(vecType(A), vecType(B), vecType(Epsilon1))) ? 0 : 1;
  46. return Error;
  47. }
  48. template <typename genType, typename valType>
  49. static int test_constexpr()
  50. {
  51. # if GLM_CONFIG_CONSTEXP == GLM_ENABLE
  52. static_assert(glm::all(glm::equal(genType(static_cast<valType>(1.01f)), genType(static_cast<valType>(1.02f)), static_cast<valType>(0.1f))), "GLM: Failed constexpr");
  53. # endif
  54. return 0;
  55. }
  56. int main()
  57. {
  58. int Error = 0;
  59. Error += test_equal<glm::vec1>();
  60. Error += test_equal<glm::lowp_vec1>();
  61. Error += test_equal<glm::mediump_vec1>();
  62. Error += test_equal<glm::highp_vec1>();
  63. Error += test_equal<glm::vec2>();
  64. Error += test_equal<glm::lowp_vec2>();
  65. Error += test_equal<glm::mediump_vec2>();
  66. Error += test_equal<glm::highp_vec2>();
  67. Error += test_equal<glm::vec3>();
  68. Error += test_equal<glm::lowp_vec3>();
  69. Error += test_equal<glm::mediump_vec3>();
  70. Error += test_equal<glm::highp_vec3>();
  71. Error += test_equal<glm::vec4>();
  72. Error += test_equal<glm::lowp_vec4>();
  73. Error += test_equal<glm::mediump_vec4>();
  74. Error += test_equal<glm::highp_vec4>();
  75. Error += test_equal<glm::dvec1>();
  76. Error += test_equal<glm::lowp_dvec1>();
  77. Error += test_equal<glm::mediump_dvec1>();
  78. Error += test_equal<glm::highp_dvec1>();
  79. Error += test_equal<glm::dvec2>();
  80. Error += test_equal<glm::lowp_dvec2>();
  81. Error += test_equal<glm::mediump_dvec2>();
  82. Error += test_equal<glm::highp_dvec2>();
  83. Error += test_equal<glm::dvec3>();
  84. Error += test_equal<glm::lowp_dvec3>();
  85. Error += test_equal<glm::mediump_dvec3>();
  86. Error += test_equal<glm::highp_dvec3>();
  87. Error += test_equal<glm::dvec4>();
  88. Error += test_equal<glm::lowp_dvec4>();
  89. Error += test_equal<glm::mediump_dvec4>();
  90. Error += test_equal<glm::highp_dvec4>();
  91. Error += test_notEqual<glm::vec1>();
  92. Error += test_notEqual<glm::lowp_vec1>();
  93. Error += test_notEqual<glm::mediump_vec1>();
  94. Error += test_notEqual<glm::highp_vec1>();
  95. Error += test_notEqual<glm::vec2>();
  96. Error += test_notEqual<glm::lowp_vec2>();
  97. Error += test_notEqual<glm::mediump_vec2>();
  98. Error += test_notEqual<glm::highp_vec2>();
  99. Error += test_notEqual<glm::vec3>();
  100. Error += test_notEqual<glm::lowp_vec3>();
  101. Error += test_notEqual<glm::mediump_vec3>();
  102. Error += test_notEqual<glm::highp_vec3>();
  103. Error += test_notEqual<glm::vec4>();
  104. Error += test_notEqual<glm::lowp_vec4>();
  105. Error += test_notEqual<glm::mediump_vec4>();
  106. Error += test_notEqual<glm::highp_vec4>();
  107. Error += test_notEqual<glm::dvec1>();
  108. Error += test_notEqual<glm::lowp_dvec1>();
  109. Error += test_notEqual<glm::mediump_dvec1>();
  110. Error += test_notEqual<glm::highp_dvec1>();
  111. Error += test_notEqual<glm::dvec2>();
  112. Error += test_notEqual<glm::lowp_dvec2>();
  113. Error += test_notEqual<glm::mediump_dvec2>();
  114. Error += test_notEqual<glm::highp_dvec2>();
  115. Error += test_notEqual<glm::dvec3>();
  116. Error += test_notEqual<glm::lowp_dvec3>();
  117. Error += test_notEqual<glm::mediump_dvec3>();
  118. Error += test_notEqual<glm::highp_dvec3>();
  119. Error += test_notEqual<glm::dvec4>();
  120. Error += test_notEqual<glm::lowp_dvec4>();
  121. Error += test_notEqual<glm::mediump_dvec4>();
  122. Error += test_notEqual<glm::highp_dvec4>();
  123. Error += test_constexpr<glm::vec1, float>();
  124. Error += test_constexpr<glm::vec2, float>();
  125. Error += test_constexpr<glm::vec3, float>();
  126. Error += test_constexpr<glm::vec4, float>();
  127. return Error;
  128. }