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.

101 lines
2.6 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/gtx/extended_min_max.hpp>
  3. #include <glm/gtc/vec1.hpp>
  4. #include <glm/gtc/constants.hpp>
  5. #include <glm/ext/scalar_relational.hpp>
  6. #include <glm/ext/vector_relational.hpp>
  7. // This file has divisions by zero to test isnan
  8. #if GLM_COMPILER & GLM_COMPILER_VC
  9. # pragma warning(disable : 4723)
  10. #endif
  11. namespace fmin_
  12. {
  13. static int test()
  14. {
  15. int Error = 0;
  16. float Zero_f = 0.0f;
  17. glm::vec1 A0 = glm::fmin(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
  18. Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
  19. glm::vec1 A1 = glm::fmin(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
  20. Error += glm::equal(A1.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
  21. glm::vec2 B0 = glm::fmin(glm::vec2(1), glm::vec2(1));
  22. glm::vec2 B1 = glm::fmin(glm::vec2(1), 1.0f);
  23. bool B2 = glm::all(glm::equal(B0, B1, glm::epsilon<float>()));
  24. Error += B2 ? 0 : 1;
  25. glm::vec3 C0 = glm::fmin(glm::vec3(1), glm::vec3(1));
  26. glm::vec3 C1 = glm::fmin(glm::vec3(1), 1.0f);
  27. bool C2 = glm::all(glm::equal(C0, C1, glm::epsilon<float>()));
  28. Error += C2 ? 0 : 1;
  29. glm::vec4 D0 = glm::fmin(glm::vec4(1), glm::vec4(1));
  30. glm::vec4 D1 = glm::fmin(glm::vec4(1), 1.0f);
  31. bool D2 = glm::all(glm::equal(D0, D1, glm::epsilon<float>()));
  32. Error += D2 ? 0 : 1;
  33. return Error;
  34. }
  35. }//namespace fmin_
  36. namespace fmax_
  37. {
  38. static int test()
  39. {
  40. int Error = 0;
  41. float Zero_f = 0.0f;
  42. glm::vec1 A0 = glm::fmax(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
  43. Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
  44. glm::vec1 A1 = glm::fmax(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
  45. Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
  46. glm::vec2 B0 = glm::fmax(glm::vec2(1), glm::vec2(1));
  47. glm::vec2 B1 = glm::fmax(glm::vec2(1), 1.0f);
  48. bool B2 = glm::all(glm::equal(B0, B1, glm::epsilon<float>()));
  49. Error += B2 ? 0 : 1;
  50. glm::vec3 C0 = glm::fmax(glm::vec3(1), glm::vec3(1));
  51. glm::vec3 C1 = glm::fmax(glm::vec3(1), 1.0f);
  52. bool C2 = glm::all(glm::equal(C0, C1, glm::epsilon<float>()));
  53. Error += C2 ? 0 : 1;
  54. glm::vec4 D0 = glm::fmax(glm::vec4(1), glm::vec4(1));
  55. glm::vec4 D1 = glm::fmax(glm::vec4(1), 1.0f);
  56. bool D2 = glm::all(glm::equal(D0, D1, glm::epsilon<float>()));
  57. Error += D2 ? 0 : 1;
  58. return Error;
  59. }
  60. }//namespace fmax_
  61. namespace fclamp_
  62. {
  63. static int test()
  64. {
  65. int Error = 0;
  66. float Zero_f = 0.0f;
  67. glm::vec1 A0 = glm::fclamp(glm::vec1(1), glm::vec1(Zero_f / 0.0f), glm::vec1(2.0f));
  68. Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
  69. return Error;
  70. }
  71. }//namespace fclamp_
  72. int main()
  73. {
  74. int Error = 0;
  75. Error += fmin_::test();
  76. Error += fmax_::test();
  77. Error += fclamp_::test();
  78. return Error;
  79. }