2
0

core_func_swizzle.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2011-10-16
  5. // Updated : 2011-10-16
  6. // Licence : This source is under MIT License
  7. // File : test/core/core_func_swizzle.cpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. //#define GLM_FORCE_ONLY_XYZW
  10. //#define GLM_FORCE_PURE
  11. #define GLM_MESSAGES
  12. #define GLM_SWIZZLE
  13. //#define GLM_FORCE_CXX98
  14. #include <glm/glm.hpp>
  15. int test_vec2_swizzle()
  16. {
  17. int Error = 0;
  18. glm::ivec2 A(1, 2);
  19. glm::ivec2 B = A.xy();
  20. glm::ivec2 C(0);
  21. C.xy() = B.xy();
  22. Error += A == B ? 0 : 1;
  23. return Error;
  24. }
  25. int test_vec3_swizzle()
  26. {
  27. int Error = 0;
  28. glm::ivec3 A(1, 2, 3);
  29. glm::ivec3 B = A.xyz();
  30. glm::ivec3 C(0);
  31. C.xyz() = B.xyz();
  32. Error += A == B ? 0 : 1;
  33. return Error;
  34. }
  35. int test_vec4_swizzle()
  36. {
  37. int Error = 0;
  38. glm::ivec4 A(1, 2, 3, 4);
  39. glm::ivec4 B = A.xyzw();
  40. glm::ivec4 C(0);
  41. C.xyzw() = B.xyzw();
  42. Error += A == B ? 0 : 1;
  43. return Error;
  44. }
  45. int main()
  46. {
  47. int Error = 0;
  48. Error += test_vec2_swizzle();
  49. Error += test_vec3_swizzle();
  50. Error += test_vec4_swizzle();
  51. return Error;
  52. }