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.

88 lines
1.7 KiB

5 years ago
  1. #include <glm/gtc/constants.hpp>
  2. #include <glm/ext/quaternion_geometric.hpp>
  3. #include <glm/ext/quaternion_float.hpp>
  4. #include <glm/ext/quaternion_trigonometric.hpp>
  5. #include <glm/ext/quaternion_float_precision.hpp>
  6. #include <glm/ext/quaternion_double.hpp>
  7. #include <glm/ext/quaternion_double_precision.hpp>
  8. #include <glm/ext/vector_float3.hpp>
  9. #include <glm/ext/vector_float3_precision.hpp>
  10. #include <glm/ext/vector_double3.hpp>
  11. #include <glm/ext/vector_double3_precision.hpp>
  12. #include <glm/ext/scalar_relational.hpp>
  13. float const Epsilon = 0.001f;
  14. static int test_length()
  15. {
  16. int Error = 0;
  17. {
  18. float const A = glm::length(glm::quat(1, 0, 0, 0));
  19. Error += glm::equal(A, 1.0f, Epsilon) ? 0 : 1;
  20. }
  21. {
  22. float const A = glm::length(glm::quat(1, glm::vec3(0)));
  23. Error += glm::equal(A, 1.0f, Epsilon) ? 0 : 1;
  24. }
  25. {
  26. float const A = glm::length(glm::quat(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0)));
  27. Error += glm::equal(A, 1.0f, Epsilon) ? 0 : 1;
  28. }
  29. return Error;
  30. }
  31. static int test_normalize()
  32. {
  33. int Error = 0;
  34. {
  35. glm::quat const A = glm::quat(1, 0, 0, 0);
  36. glm::quat const N = glm::normalize(A);
  37. Error += glm::all(glm::equal(A, N, Epsilon)) ? 0 : 1;
  38. }
  39. {
  40. glm::quat const A = glm::quat(1, glm::vec3(0));
  41. glm::quat const N = glm::normalize(A);
  42. Error += glm::all(glm::equal(A, N, Epsilon)) ? 0 : 1;
  43. }
  44. return Error;
  45. }
  46. static int test_dot()
  47. {
  48. int Error = 0;
  49. {
  50. glm::quat const A = glm::quat(1, 0, 0, 0);
  51. glm::quat const B = glm::quat(1, 0, 0, 0);
  52. float const C = glm::dot(A, B);
  53. Error += glm::equal(C, 1.0f, Epsilon) ? 0 : 1;
  54. }
  55. return Error;
  56. }
  57. static int test_cross()
  58. {
  59. int Error = 0;
  60. return Error;
  61. }
  62. int main()
  63. {
  64. int Error = 0;
  65. Error += test_length();
  66. Error += test_normalize();
  67. Error += test_dot();
  68. Error += test_cross();
  69. return Error;
  70. }