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.

83 lines
1.2 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/gtc/constants.hpp>
  3. #include <glm/ext/scalar_relational.hpp>
  4. #include <glm/ext/vector_relational.hpp>
  5. #include <glm/glm.hpp>
  6. #if GLM_HAS_RANGE_FOR
  7. #include <glm/gtx/range.hpp>
  8. int test_vec()
  9. {
  10. int Error = 0;
  11. {
  12. glm::ivec3 const v(1, 2, 3);
  13. int count = 0;
  14. glm::ivec3 Result(0);
  15. for(int x : v)
  16. {
  17. Result[count] = x;
  18. count++;
  19. }
  20. Error += count == 3 ? 0 : 1;
  21. Error += v == Result ? 0 : 1;
  22. }
  23. {
  24. glm::ivec3 v(1, 2, 3);
  25. for(int& x : v)
  26. x = 0;
  27. Error += glm::all(glm::equal(v, glm::ivec3(0))) ? 0 : 1;
  28. }
  29. return Error;
  30. }
  31. int test_mat()
  32. {
  33. int Error = 0;
  34. {
  35. glm::mat4x3 m(1.0f);
  36. int count = 0;
  37. float Sum = 0.0f;
  38. for(float x : m)
  39. {
  40. count++;
  41. Sum += x;
  42. }
  43. Error += count == 12 ? 0 : 1;
  44. Error += glm::equal(Sum, 3.0f, 0.001f) ? 0 : 1;
  45. }
  46. {
  47. glm::mat4x3 m(1.0f);
  48. for (float& x : m) { x = 0; }
  49. glm::vec4 v(1, 1, 1, 1);
  50. Error += glm::all(glm::equal(m*v, glm::vec3(0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
  51. }
  52. return Error;
  53. }
  54. int main()
  55. {
  56. int Error = 0;
  57. Error += test_vec();
  58. Error += test_mat();
  59. return Error;
  60. }
  61. #else
  62. int main()
  63. {
  64. return 0;
  65. }
  66. #endif//GLM_HAS_RANGE_FOR