core_func_swizzle.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. Error += A == C ? 0 : 1;
  24. return Error;
  25. }
  26. int test_vec3_swizzle()
  27. {
  28. int Error = 0;
  29. glm::ivec3 A(1, 2, 3);
  30. glm::ivec3 B = A.xyz();
  31. glm::ivec3 C(0);
  32. C.xyz() = B.xyz();
  33. Error += A == B ? 0 : 1;
  34. Error += A == C ? 0 : 1;
  35. return Error;
  36. }
  37. int test_vec4_swizzle()
  38. {
  39. int Error = 0;
  40. glm::ivec4 A(1, 2, 3, 4);
  41. glm::ivec4 B = A.xyzw();
  42. glm::ivec4 C(0);
  43. C.xyzw() = B.xyzw();
  44. Error += A == B ? 0 : 1;
  45. Error += A == C ? 0 : 1;
  46. return Error;
  47. }
  48. int main()
  49. {
  50. int Error = 0;
  51. Error += test_vec2_swizzle();
  52. Error += test_vec3_swizzle();
  53. Error += test_vec4_swizzle();
  54. return Error;
  55. }