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.

45 lines
1.4 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/gtx/fast_square_root.hpp>
  3. #include <glm/gtc/type_precision.hpp>
  4. #include <glm/gtc/epsilon.hpp>
  5. #include <glm/vector_relational.hpp>
  6. int test_fastInverseSqrt()
  7. {
  8. int Error = 0;
  9. Error += glm::epsilonEqual(glm::fastInverseSqrt(1.0f), 1.0f, 0.01f) ? 0 : 1;
  10. Error += glm::epsilonEqual(glm::fastInverseSqrt(1.0), 1.0, 0.01) ? 0 : 1;
  11. Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::vec2(1.0f)), glm::vec2(1.0f), 0.01f)) ? 0 : 1;
  12. Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::dvec3(1.0)), glm::dvec3(1.0), 0.01)) ? 0 : 1;
  13. Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::dvec4(1.0)), glm::dvec4(1.0), 0.01)) ? 0 : 1;
  14. return 0;
  15. }
  16. int test_fastDistance()
  17. {
  18. int Error = 0;
  19. float const A = glm::fastDistance(0.0f, 1.0f);
  20. float const B = glm::fastDistance(glm::vec2(0.0f), glm::vec2(1.0f, 0.0f));
  21. float const C = glm::fastDistance(glm::vec3(0.0f), glm::vec3(1.0f, 0.0f, 0.0f));
  22. float const D = glm::fastDistance(glm::vec4(0.0f), glm::vec4(1.0f, 0.0f, 0.0f, 0.0f));
  23. Error += glm::epsilonEqual(A, 1.0f, 0.01f) ? 0 : 1;
  24. Error += glm::epsilonEqual(B, 1.0f, 0.01f) ? 0 : 1;
  25. Error += glm::epsilonEqual(C, 1.0f, 0.01f) ? 0 : 1;
  26. Error += glm::epsilonEqual(D, 1.0f, 0.01f) ? 0 : 1;
  27. return Error;
  28. }
  29. int main()
  30. {
  31. int Error = 0;
  32. Error += test_fastInverseSqrt();
  33. Error += test_fastDistance();
  34. return Error;
  35. }