core_func_trigonometric.cpp 4.0 KB

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