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.

174 lines
4.8 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/gtx/scalar_relational.hpp>
  3. #include <glm/gtc/constants.hpp>
  4. #include <glm/ext/scalar_relational.hpp>
  5. #include <glm/ext/vector_relational.hpp>
  6. #include <glm/ext/matrix_relational.hpp>
  7. #include <glm/glm.hpp>
  8. static int test_lessThan()
  9. {
  10. int Error = 0;
  11. Error += glm::lessThan(0, 1) ? 0 : 1;
  12. Error += glm::lessThan(1, 0) ? 1 : 0;
  13. Error += glm::lessThan(0, 0) ? 1 : 0;
  14. Error += glm::lessThan(1, 1) ? 1 : 0;
  15. Error += glm::lessThan(0.0f, 1.0f) ? 0 : 1;
  16. Error += glm::lessThan(1.0f, 0.0f) ? 1 : 0;
  17. Error += glm::lessThan(0.0f, 0.0f) ? 1 : 0;
  18. Error += glm::lessThan(1.0f, 1.0f) ? 1 : 0;
  19. Error += glm::lessThan(0.0, 1.0) ? 0 : 1;
  20. Error += glm::lessThan(1.0, 0.0) ? 1 : 0;
  21. Error += glm::lessThan(0.0, 0.0) ? 1 : 0;
  22. Error += glm::lessThan(1.0, 1.0) ? 1 : 0;
  23. return Error;
  24. }
  25. static int test_lessThanEqual()
  26. {
  27. int Error = 0;
  28. Error += glm::lessThanEqual(0, 1) ? 0 : 1;
  29. Error += glm::lessThanEqual(1, 0) ? 1 : 0;
  30. Error += glm::lessThanEqual(0, 0) ? 0 : 1;
  31. Error += glm::lessThanEqual(1, 1) ? 0 : 1;
  32. Error += glm::lessThanEqual(0.0f, 1.0f) ? 0 : 1;
  33. Error += glm::lessThanEqual(1.0f, 0.0f) ? 1 : 0;
  34. Error += glm::lessThanEqual(0.0f, 0.0f) ? 0 : 1;
  35. Error += glm::lessThanEqual(1.0f, 1.0f) ? 0 : 1;
  36. Error += glm::lessThanEqual(0.0, 1.0) ? 0 : 1;
  37. Error += glm::lessThanEqual(1.0, 0.0) ? 1 : 0;
  38. Error += glm::lessThanEqual(0.0, 0.0) ? 0 : 1;
  39. Error += glm::lessThanEqual(1.0, 1.0) ? 0 : 1;
  40. return Error;
  41. }
  42. static int test_greaterThan()
  43. {
  44. int Error = 0;
  45. Error += glm::greaterThan(0, 1) ? 1 : 0;
  46. Error += glm::greaterThan(1, 0) ? 0 : 1;
  47. Error += glm::greaterThan(0, 0) ? 1 : 0;
  48. Error += glm::greaterThan(1, 1) ? 1 : 0;
  49. Error += glm::greaterThan(0.0f, 1.0f) ? 1 : 0;
  50. Error += glm::greaterThan(1.0f, 0.0f) ? 0 : 1;
  51. Error += glm::greaterThan(0.0f, 0.0f) ? 1 : 0;
  52. Error += glm::greaterThan(1.0f, 1.0f) ? 1 : 0;
  53. Error += glm::greaterThan(0.0, 1.0) ? 1 : 0;
  54. Error += glm::greaterThan(1.0, 0.0) ? 0 : 1;
  55. Error += glm::greaterThan(0.0, 0.0) ? 1 : 0;
  56. Error += glm::greaterThan(1.0, 1.0) ? 1 : 0;
  57. return Error;
  58. }
  59. static int test_greaterThanEqual()
  60. {
  61. int Error = 0;
  62. Error += glm::greaterThanEqual(0, 1) ? 1 : 0;
  63. Error += glm::greaterThanEqual(1, 0) ? 0 : 1;
  64. Error += glm::greaterThanEqual(0, 0) ? 0 : 1;
  65. Error += glm::greaterThanEqual(1, 1) ? 0 : 1;
  66. Error += glm::greaterThanEqual(0.0f, 1.0f) ? 1 : 0;
  67. Error += glm::greaterThanEqual(1.0f, 0.0f) ? 0 : 1;
  68. Error += glm::greaterThanEqual(0.0f, 0.0f) ? 0 : 1;
  69. Error += glm::greaterThanEqual(1.0f, 1.0f) ? 0 : 1;
  70. Error += glm::greaterThanEqual(0.0, 1.0) ? 1 : 0;
  71. Error += glm::greaterThanEqual(1.0, 0.0) ? 0 : 1;
  72. Error += glm::greaterThanEqual(0.0, 0.0) ? 0 : 1;
  73. Error += glm::greaterThanEqual(1.0, 1.0) ? 0 : 1;
  74. return Error;
  75. }
  76. static int test_equal()
  77. {
  78. int Error = 0;
  79. Error += glm::equal(0, 1) ? 1 : 0;
  80. Error += glm::equal(1, 0) ? 1 : 0;
  81. Error += glm::equal(0, 0) ? 0 : 1;
  82. Error += glm::equal(1, 1) ? 0 : 1;
  83. Error += glm::equal(0.0f, 1.0f, glm::epsilon<float>()) ? 1 : 0;
  84. Error += glm::equal(1.0f, 0.0f, glm::epsilon<float>()) ? 1 : 0;
  85. Error += glm::equal(0.0f, 0.0f, glm::epsilon<float>()) ? 0 : 1;
  86. Error += glm::equal(1.0f, 1.0f, glm::epsilon<float>()) ? 0 : 1;
  87. Error += glm::equal(0.0, 1.0, glm::epsilon<double>()) ? 1 : 0;
  88. Error += glm::equal(1.0, 0.0, glm::epsilon<double>()) ? 1 : 0;
  89. Error += glm::equal(0.0, 0.0, glm::epsilon<double>()) ? 0 : 1;
  90. Error += glm::equal(1.0, 1.0, glm::epsilon<double>()) ? 0 : 1;
  91. return Error;
  92. }
  93. static int test_notEqual()
  94. {
  95. int Error = 0;
  96. Error += glm::notEqual(0, 1) ? 0 : 1;
  97. Error += glm::notEqual(1, 0) ? 0 : 1;
  98. Error += glm::notEqual(0, 0) ? 1 : 0;
  99. Error += glm::notEqual(1, 1) ? 1 : 0;
  100. Error += glm::notEqual(0.0f, 1.0f, glm::epsilon<float>()) ? 0 : 1;
  101. Error += glm::notEqual(1.0f, 0.0f, glm::epsilon<float>()) ? 0 : 1;
  102. Error += glm::notEqual(0.0f, 0.0f, glm::epsilon<float>()) ? 1 : 0;
  103. Error += glm::notEqual(1.0f, 1.0f, glm::epsilon<float>()) ? 1 : 0;
  104. Error += glm::notEqual(0.0, 1.0, glm::epsilon<double>()) ? 0 : 1;
  105. Error += glm::notEqual(1.0, 0.0, glm::epsilon<double>()) ? 0 : 1;
  106. Error += glm::notEqual(0.0, 0.0, glm::epsilon<double>()) ? 1 : 0;
  107. Error += glm::notEqual(1.0, 1.0, glm::epsilon<double>()) ? 1 : 0;
  108. return Error;
  109. }
  110. static int test_any()
  111. {
  112. int Error = 0;
  113. Error += glm::any(true) ? 0 : 1;
  114. Error += glm::any(false) ? 1 : 0;
  115. return Error;
  116. }
  117. static int test_all()
  118. {
  119. int Error = 0;
  120. Error += glm::all(true) ? 0 : 1;
  121. Error += glm::all(false) ? 1 : 0;
  122. return Error;
  123. }
  124. static int test_not()
  125. {
  126. int Error = 0;
  127. Error += glm::not_(true) ? 1 : 0;
  128. Error += glm::not_(false) ? 0 : 1;
  129. return Error;
  130. }
  131. int main()
  132. {
  133. int Error = 0;
  134. Error += test_lessThan();
  135. Error += test_lessThanEqual();
  136. Error += test_greaterThan();
  137. Error += test_greaterThanEqual();
  138. Error += test_equal();
  139. Error += test_notEqual();
  140. Error += test_any();
  141. Error += test_all();
  142. Error += test_not();
  143. return Error;
  144. }