gtx_range.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2014-09-19
  5. // Updated : 2014-09-19
  6. // Licence : This source is under MIT licence
  7. // File : test/gtx/gtx_range.cpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #include <glm/glm.hpp>
  10. #include <glm/gtc/epsilon.hpp>
  11. #if GLM_HAS_RANGE_FOR
  12. #include <glm/gtx/range.hpp>
  13. int testVec()
  14. {
  15. int Error(0);
  16. glm::vec3 v(1, 2, 3);
  17. int count = 0;
  18. for(float x : v){ count++; }
  19. Error += count == 3 ? 0 : 1;
  20. for(float& x : v){ x = 0; }
  21. Error += glm::all(glm::equal(v, glm::vec3(0, 0, 0))) ? 0 : 1;
  22. return Error;
  23. }
  24. int testMat()
  25. {
  26. int Error(0);
  27. glm::mat4x3 m(1);
  28. int count = 0;
  29. for(float x : m){ count++; }
  30. Error += count == 12 ? 0 : 1;
  31. for(float& x : m){ x = 0; }
  32. glm::vec4 v(1, 1, 1, 1);
  33. Error += glm::all(glm::equal(m*v, glm::vec3(0, 0, 0))) ? 0 : 1;
  34. return Error;
  35. }
  36. int main()
  37. {
  38. int Error(0);
  39. Error += testVec();
  40. Error += testMat();
  41. return Error;
  42. }
  43. #else
  44. int main()
  45. {
  46. return 0;
  47. }
  48. #endif//GLM_HAS_RANGE_FOR