core_func_integer.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2011-01-15
  5. // Updated : 2011-01-15
  6. // Licence : This source is under MIT licence
  7. // File : test/gtx/simd-mat4.cpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
  10. #include <glm/glm.hpp>
  11. int test_static_assert()
  12. {
  13. //glm::lessThan(glm::mat4(0), glm::mat4(4));
  14. return 0;
  15. }
  16. int test_lessThan_vec2()
  17. {
  18. glm::bvec2 O = glm::bvec2(true, false);
  19. glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2));
  20. assert(glm::all(glm::equal(O, A)));
  21. glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2));
  22. assert(glm::all(glm::equal(O, B)));
  23. glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2));
  24. assert(glm::all(glm::equal(O, C)));
  25. return 0;
  26. }
  27. int test_lessThan_vec3()
  28. {
  29. glm::bvec3 O = glm::bvec3(true, true, false);
  30. glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2));
  31. assert(glm::all(glm::equal(O, A)));
  32. glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2));
  33. assert(glm::all(glm::equal(O, B)));
  34. glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2));
  35. assert(glm::all(glm::equal(O, C)));
  36. return 0;
  37. }
  38. int test_lessThan_vec4()
  39. {
  40. glm::bvec4 O = glm::bvec4(true, true, false, false);
  41. glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3));
  42. assert(glm::all(glm::equal(O, A)));
  43. glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3));
  44. assert(glm::all(glm::equal(O, B)));
  45. glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3));
  46. assert(glm::all(glm::equal(O, C)));
  47. return 0;
  48. }
  49. int test_greaterThanEqual_vec2()
  50. {
  51. glm::bvec2 O = glm::bvec2(false, true);
  52. glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2));
  53. assert(glm::all(glm::equal(O, A)));
  54. glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2));
  55. assert(glm::all(glm::equal(O, B)));
  56. glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2));
  57. assert(glm::all(glm::equal(O, C)));
  58. return 0;
  59. }
  60. int test_greaterThanEqual_vec3()
  61. {
  62. glm::bvec3 O = glm::bvec3(false, false, true);
  63. glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2));
  64. assert(glm::all(glm::equal(O, A)));
  65. glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2));
  66. assert(glm::all(glm::equal(O, B)));
  67. glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2));
  68. assert(glm::all(glm::equal(O, C)));
  69. return 0;
  70. }
  71. int test_greaterThanEqual_vec4()
  72. {
  73. glm::bvec4 O = glm::bvec4(false, false, true, true);
  74. glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3));
  75. assert(glm::all(glm::equal(O, A)));
  76. glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3));
  77. assert(glm::all(glm::equal(O, B)));
  78. glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3));
  79. assert(glm::all(glm::equal(O, C)));
  80. return 0;
  81. }
  82. int test_all()
  83. {
  84. assert(glm::all(glm::bvec2(true, true)));
  85. assert(!glm::all(glm::bvec2(true, false)));
  86. assert(!glm::all(glm::bvec2(false, false)));
  87. assert(glm::all(glm::bvec3(true, true, true)));
  88. assert(!glm::all(glm::bvec3(true, false, true)));
  89. assert(!glm::all(glm::bvec3(false, false, false)));
  90. assert(glm::all(glm::bvec4(true, true, true, true)));
  91. assert(!glm::all(glm::bvec4(true, false, true, false)));
  92. assert(!glm::all(glm::bvec4(false, false, false, false)));
  93. return 0;
  94. }
  95. int main(int argc, void* argv[])
  96. {
  97. int Failed = 0;
  98. Failed += test_static_assert();
  99. Failed += test_lessThan_vec2();
  100. Failed += test_lessThan_vec3();
  101. Failed += test_lessThan_vec4();
  102. Failed += test_greaterThanEqual_vec2();
  103. Failed += test_greaterThanEqual_vec3();
  104. Failed += test_greaterThanEqual_vec4();
  105. Failed += test_all();
  106. return Failed;
  107. }