core_func_common.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2011-01-15
  5. // Updated : 2011-09-13
  6. // Licence : This source is under MIT licence
  7. // File : test/core/func_common.cpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #include <glm/glm.hpp>
  10. int test_floatBitsToInt()
  11. {
  12. int Error = 0;
  13. {
  14. float A = 1.0f;
  15. int B = glm::floatBitsToInt(A);
  16. Error += B == *(float*)&A ? 0 : 1;
  17. }
  18. {
  19. glm::vec2 A(1.0f, 2.0f);
  20. glm::ivec2 B = glm::floatBitsToInt(A);
  21. Error += B.x == *(float*)&(A.x) ? 0 : 1;
  22. Error += B.y == *(float*)&(A.y) ? 0 : 1;
  23. }
  24. return Error;
  25. }
  26. int test_mix()
  27. {
  28. int Error = 0;
  29. {
  30. float A = glm::mix(0.f, 1.f, true);
  31. Error += A == 1.f ? 0 : 1;
  32. float B = glm::mix(0.f, 1.f, false);
  33. Error += B == 0.f ? 0 : 1;
  34. }
  35. {
  36. float A = glm::mix(0.f, 1.f, 1.f);
  37. Error += A == 1.f ? 0 : 1;
  38. float B = glm::mix(0.f, 1.f, 0.f);
  39. Error += B == 0.f ? 0 : 1;
  40. }
  41. return Error;
  42. }
  43. int main()
  44. {
  45. int Error = 0;
  46. Error += test_floatBitsToInt();
  47. Error += test_mix();
  48. return Error;
  49. }