Platformer in OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
4.8 KiB

5 years ago
  1. #include <glm/ext/vector_int1.hpp>
  2. #include <glm/ext/vector_int1_precision.hpp>
  3. #include <glm/ext/vector_int2.hpp>
  4. #include <glm/ext/vector_int3.hpp>
  5. #include <glm/ext/vector_int4.hpp>
  6. #include <glm/ext/vector_uint1.hpp>
  7. #include <glm/ext/vector_uint1_precision.hpp>
  8. #include <glm/ext/vector_uint2.hpp>
  9. #include <glm/ext/vector_uint3.hpp>
  10. #include <glm/ext/vector_uint4.hpp>
  11. #include <glm/vector_relational.hpp>
  12. template <typename genType>
  13. static int test_operators()
  14. {
  15. int Error = 0;
  16. {
  17. genType const A(1);
  18. genType const B(1);
  19. bool const R = A != B;
  20. bool const S = A == B;
  21. Error += (S && !R) ? 0 : 1;
  22. }
  23. {
  24. genType const A(1);
  25. genType const B(1);
  26. genType const C = A + B;
  27. Error += C == genType(2) ? 0 : 1;
  28. genType const D = A - B;
  29. Error += D == genType(0) ? 0 : 1;
  30. genType const E = A * B;
  31. Error += E == genType(1) ? 0 : 1;
  32. genType const F = A / B;
  33. Error += F == genType(1) ? 0 : 1;
  34. }
  35. {
  36. genType const A(3);
  37. genType const B(2);
  38. genType const C = A % B;
  39. Error += C == genType(1) ? 0 : 1;
  40. }
  41. {
  42. genType const A(1);
  43. genType const B(1);
  44. genType const C(0);
  45. genType const I = A & B;
  46. Error += I == genType(1) ? 0 : 1;
  47. genType const D = A & C;
  48. Error += D == genType(0) ? 0 : 1;
  49. genType const E = A | B;
  50. Error += E == genType(1) ? 0 : 1;
  51. genType const F = A | C;
  52. Error += F == genType(1) ? 0 : 1;
  53. genType const G = A ^ B;
  54. Error += G == genType(0) ? 0 : 1;
  55. genType const H = A ^ C;
  56. Error += H == genType(1) ? 0 : 1;
  57. }
  58. {
  59. genType const A(0);
  60. genType const B(1);
  61. genType const C(2);
  62. genType const D = B << B;
  63. Error += D == genType(2) ? 0 : 1;
  64. genType const E = C >> B;
  65. Error += E == genType(1) ? 0 : 1;
  66. }
  67. return Error;
  68. }
  69. template <typename genType>
  70. static int test_ctor()
  71. {
  72. typedef typename genType::value_type T;
  73. int Error = 0;
  74. genType const A = genType(1);
  75. genType const E(genType(1));
  76. Error += A == E ? 0 : 1;
  77. genType const F(E);
  78. Error += A == F ? 0 : 1;
  79. genType const B = genType(1);
  80. genType const G(glm::vec<2, T>(1));
  81. Error += B == G ? 0 : 1;
  82. genType const H(glm::vec<3, T>(1));
  83. Error += B == H ? 0 : 1;
  84. genType const I(glm::vec<4, T>(1));
  85. Error += B == I ? 0 : 1;
  86. return Error;
  87. }
  88. template <typename genType>
  89. static int test_size()
  90. {
  91. int Error = 0;
  92. Error += sizeof(typename genType::value_type) == sizeof(genType) ? 0 : 1;
  93. Error += genType().length() == 1 ? 0 : 1;
  94. Error += genType::length() == 1 ? 0 : 1;
  95. return Error;
  96. }
  97. template <typename genType>
  98. static int test_relational()
  99. {
  100. int Error = 0;
  101. genType const A(1);
  102. genType const B(1);
  103. genType const C(0);
  104. Error += A == B ? 0 : 1;
  105. Error += A != C ? 0 : 1;
  106. Error += all(equal(A, B)) ? 0 : 1;
  107. Error += any(notEqual(A, C)) ? 0 : 1;
  108. return Error;
  109. }
  110. template <typename genType>
  111. static int test_constexpr()
  112. {
  113. # if GLM_CONFIG_CONSTEXP == GLM_ENABLE
  114. static_assert(genType::length() == 1, "GLM: Failed constexpr");
  115. static_assert(genType(1)[0] == 1, "GLM: Failed constexpr");
  116. static_assert(genType(1) == genType(1), "GLM: Failed constexpr");
  117. static_assert(genType(1) != genType(0), "GLM: Failed constexpr");
  118. # endif
  119. return 0;
  120. }
  121. int main()
  122. {
  123. int Error = 0;
  124. Error += test_operators<glm::ivec1>();
  125. Error += test_operators<glm::lowp_ivec1>();
  126. Error += test_operators<glm::mediump_ivec1>();
  127. Error += test_operators<glm::highp_ivec1>();
  128. Error += test_ctor<glm::ivec1>();
  129. Error += test_ctor<glm::lowp_ivec1>();
  130. Error += test_ctor<glm::mediump_ivec1>();
  131. Error += test_ctor<glm::highp_ivec1>();
  132. Error += test_size<glm::ivec1>();
  133. Error += test_size<glm::lowp_ivec1>();
  134. Error += test_size<glm::mediump_ivec1>();
  135. Error += test_size<glm::highp_ivec1>();
  136. Error += test_relational<glm::ivec1>();
  137. Error += test_relational<glm::lowp_ivec1>();
  138. Error += test_relational<glm::mediump_ivec1>();
  139. Error += test_relational<glm::highp_ivec1>();
  140. Error += test_constexpr<glm::ivec1>();
  141. Error += test_constexpr<glm::lowp_ivec1>();
  142. Error += test_constexpr<glm::mediump_ivec1>();
  143. Error += test_constexpr<glm::highp_ivec1>();
  144. Error += test_operators<glm::uvec1>();
  145. Error += test_operators<glm::lowp_uvec1>();
  146. Error += test_operators<glm::mediump_uvec1>();
  147. Error += test_operators<glm::highp_uvec1>();
  148. Error += test_ctor<glm::uvec1>();
  149. Error += test_ctor<glm::lowp_uvec1>();
  150. Error += test_ctor<glm::mediump_uvec1>();
  151. Error += test_ctor<glm::highp_uvec1>();
  152. Error += test_size<glm::uvec1>();
  153. Error += test_size<glm::lowp_uvec1>();
  154. Error += test_size<glm::mediump_uvec1>();
  155. Error += test_size<glm::highp_uvec1>();
  156. Error += test_relational<glm::uvec1>();
  157. Error += test_relational<glm::lowp_uvec1>();
  158. Error += test_relational<glm::mediump_uvec1>();
  159. Error += test_relational<glm::highp_uvec1>();
  160. Error += test_constexpr<glm::uvec1>();
  161. Error += test_constexpr<glm::lowp_uvec1>();
  162. Error += test_constexpr<glm::mediump_uvec1>();
  163. Error += test_constexpr<glm::highp_uvec1>();
  164. return Error;
  165. }