core_func_swizzle.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2012 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. #ifndef GLM_FORCE_ONLY_XYZW
  10. # define GLM_FORCE_ONLY_XYZW
  11. #endif
  12. //#ifndef GLM_FORCE_PURE
  13. //# define GLM_FORCE_PURE
  14. //#endif
  15. #ifndef GLM_MESSAGES
  16. # define GLM_MESSAGES
  17. #endif
  18. #ifndef GLM_SWIZZLE
  19. # define GLM_SWIZZLE
  20. #endif
  21. #ifndef GLM_FORCE_CXX98
  22. # define GLM_FORCE_CXX98
  23. #endif
  24. #include <glm/glm.hpp>
  25. int test_vec2_swizzle()
  26. {
  27. int Error = 0;
  28. glm::ivec2 A(1, 2);
  29. glm::ivec2 B = A.xy();
  30. glm::ivec2 C(0);
  31. C.xy() = B.xy();
  32. Error += A == B ? 0 : 1;
  33. Error += A == C ? 0 : 1;
  34. return Error;
  35. }
  36. int test_vec3_swizzle()
  37. {
  38. int Error = 0;
  39. glm::ivec3 A(1, 2, 3);
  40. glm::ivec3 B = A.xyz();
  41. glm::ivec3 C(0);
  42. C.xyz() = B.xyz();
  43. Error += A == B ? 0 : 1;
  44. Error += A == C ? 0 : 1;
  45. return Error;
  46. }
  47. int test_vec4_swizzle()
  48. {
  49. int Error = 0;
  50. glm::ivec4 A(1, 2, 3, 4);
  51. glm::ivec4 B = A.xyzw();
  52. glm::ivec4 C(0);
  53. C.xyzw() = B.xyzw();
  54. Error += A == B ? 0 : 1;
  55. Error += A == C ? 0 : 1;
  56. return Error;
  57. }
  58. int main()
  59. {
  60. int Error = 0;
  61. Error += test_vec2_swizzle();
  62. Error += test_vec3_swizzle();
  63. Error += test_vec4_swizzle();
  64. return Error;
  65. }