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.

190 lines
5.4 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/gtx/wrap.hpp>
  3. #include <glm/gtc/epsilon.hpp>
  4. namespace clamp
  5. {
  6. int test()
  7. {
  8. int Error(0);
  9. float A = glm::clamp(0.5f);
  10. Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
  11. float B = glm::clamp(0.0f);
  12. Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
  13. float C = glm::clamp(1.0f);
  14. Error += glm::epsilonEqual(C, 1.0f, 0.00001f) ? 0 : 1;
  15. float D = glm::clamp(-0.5f);
  16. Error += glm::epsilonEqual(D, 0.0f, 0.00001f) ? 0 : 1;
  17. float E = glm::clamp(1.5f);
  18. Error += glm::epsilonEqual(E, 1.0f, 0.00001f) ? 0 : 1;
  19. glm::vec2 K = glm::clamp(glm::vec2(0.5f));
  20. Error += glm::all(glm::epsilonEqual(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1;
  21. glm::vec3 L = glm::clamp(glm::vec3(0.5f));
  22. Error += glm::all(glm::epsilonEqual(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1;
  23. glm::vec4 M = glm::clamp(glm::vec4(0.5f));
  24. Error += glm::all(glm::epsilonEqual(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1;
  25. glm::vec1 N = glm::clamp(glm::vec1(0.5f));
  26. Error += glm::all(glm::epsilonEqual(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1;
  27. return Error;
  28. }
  29. }//namespace clamp
  30. namespace repeat
  31. {
  32. int test()
  33. {
  34. int Error(0);
  35. float A = glm::repeat(0.5f);
  36. Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
  37. float B = glm::repeat(0.0f);
  38. Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
  39. float C = glm::repeat(1.0f);
  40. Error += glm::epsilonEqual(C, 0.0f, 0.00001f) ? 0 : 1;
  41. float D = glm::repeat(-0.5f);
  42. Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1;
  43. float E = glm::repeat(1.5f);
  44. Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1;
  45. float F = glm::repeat(0.9f);
  46. Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1;
  47. glm::vec2 K = glm::repeat(glm::vec2(0.5f));
  48. Error += glm::all(glm::epsilonEqual(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1;
  49. glm::vec3 L = glm::repeat(glm::vec3(0.5f));
  50. Error += glm::all(glm::epsilonEqual(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1;
  51. glm::vec4 M = glm::repeat(glm::vec4(0.5f));
  52. Error += glm::all(glm::epsilonEqual(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1;
  53. glm::vec1 N = glm::repeat(glm::vec1(0.5f));
  54. Error += glm::all(glm::epsilonEqual(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1;
  55. return Error;
  56. }
  57. }//namespace repeat
  58. namespace mirrorClamp
  59. {
  60. int test()
  61. {
  62. int Error(0);
  63. float A = glm::mirrorClamp(0.5f);
  64. Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
  65. float B = glm::mirrorClamp(0.0f);
  66. Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
  67. float C = glm::mirrorClamp(1.1f);
  68. Error += glm::epsilonEqual(C, 0.1f, 0.00001f) ? 0 : 1;
  69. float D = glm::mirrorClamp(-0.5f);
  70. Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1;
  71. float E = glm::mirrorClamp(1.5f);
  72. Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1;
  73. float F = glm::mirrorClamp(0.9f);
  74. Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1;
  75. float G = glm::mirrorClamp(3.1f);
  76. Error += glm::epsilonEqual(G, 0.1f, 0.00001f) ? 0 : 1;
  77. float H = glm::mirrorClamp(-3.1f);
  78. Error += glm::epsilonEqual(H, 0.1f, 0.00001f) ? 0 : 1;
  79. float I = glm::mirrorClamp(-0.9f);
  80. Error += glm::epsilonEqual(I, 0.9f, 0.00001f) ? 0 : 1;
  81. glm::vec2 K = glm::mirrorClamp(glm::vec2(0.5f));
  82. Error += glm::all(glm::epsilonEqual(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1;
  83. glm::vec3 L = glm::mirrorClamp(glm::vec3(0.5f));
  84. Error += glm::all(glm::epsilonEqual(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1;
  85. glm::vec4 M = glm::mirrorClamp(glm::vec4(0.5f));
  86. Error += glm::all(glm::epsilonEqual(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1;
  87. glm::vec1 N = glm::mirrorClamp(glm::vec1(0.5f));
  88. Error += glm::all(glm::epsilonEqual(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1;
  89. return Error;
  90. }
  91. }//namespace mirrorClamp
  92. namespace mirrorRepeat
  93. {
  94. int test()
  95. {
  96. int Error(0);
  97. float A = glm::mirrorRepeat(0.5f);
  98. Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
  99. float B = glm::mirrorRepeat(0.0f);
  100. Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
  101. float C = glm::mirrorRepeat(1.0f);
  102. Error += glm::epsilonEqual(C, 1.0f, 0.00001f) ? 0 : 1;
  103. float D = glm::mirrorRepeat(-0.5f);
  104. Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1;
  105. float E = glm::mirrorRepeat(1.5f);
  106. Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1;
  107. float F = glm::mirrorRepeat(0.9f);
  108. Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1;
  109. float G = glm::mirrorRepeat(3.0f);
  110. Error += glm::epsilonEqual(G, 1.0f, 0.00001f) ? 0 : 1;
  111. float H = glm::mirrorRepeat(-3.0f);
  112. Error += glm::epsilonEqual(H, 1.0f, 0.00001f) ? 0 : 1;
  113. float I = glm::mirrorRepeat(-1.0f);
  114. Error += glm::epsilonEqual(I, 1.0f, 0.00001f) ? 0 : 1;
  115. glm::vec2 K = glm::mirrorRepeat(glm::vec2(0.5f));
  116. Error += glm::all(glm::epsilonEqual(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1;
  117. glm::vec3 L = glm::mirrorRepeat(glm::vec3(0.5f));
  118. Error += glm::all(glm::epsilonEqual(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1;
  119. glm::vec4 M = glm::mirrorRepeat(glm::vec4(0.5f));
  120. Error += glm::all(glm::epsilonEqual(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1;
  121. glm::vec1 N = glm::mirrorRepeat(glm::vec1(0.5f));
  122. Error += glm::all(glm::epsilonEqual(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1;
  123. return Error;
  124. }
  125. }//namespace mirrorRepeat
  126. int main()
  127. {
  128. int Error(0);
  129. Error += clamp::test();
  130. Error += repeat::test();
  131. Error += mirrorClamp::test();
  132. Error += mirrorRepeat::test();
  133. return Error;
  134. }