core_func_swizzle.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_MESSAGES
  10. #define GLM_SWIZZLE_OPERATOR
  11. //#define GLM_FORCE_CXX11
  12. #include <glm/glm.hpp>
  13. int test_vec2_swizzle()
  14. {
  15. int Error = 0;
  16. glm::ivec2 A(1, 2);
  17. glm::ivec2 B = A.xy();
  18. glm::ivec2 C(0);
  19. C.xy() = B.xy();
  20. Error += A == B ? 0 : 1;
  21. return Error;
  22. }
  23. int test_vec3_swizzle()
  24. {
  25. int Error = 0;
  26. glm::ivec3 A(1, 2, 3);
  27. glm::ivec3 B = A.xyz();
  28. glm::ivec3 C(0);
  29. C.xyz() = B.xyz();
  30. Error += A == B ? 0 : 1;
  31. return Error;
  32. }
  33. int test_vec4_swizzle()
  34. {
  35. int Error = 0;
  36. glm::ivec4 A(1, 2, 3, 4);
  37. glm::ivec4 B = A.xyzw();
  38. glm::ivec4 C(0);
  39. C.xyzw() = B.xyzw();
  40. Error += A == B ? 0 : 1;
  41. return Error;
  42. }
  43. int main()
  44. {
  45. int Error = 0;
  46. Error += test_vec2_swizzle();
  47. Error += test_vec3_swizzle();
  48. Error += test_vec4_swizzle();
  49. return Error;
  50. }