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.

100 lines
2.0 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/vec2.hpp>
  3. #include <glm/vec3.hpp>
  4. #include <glm/vec4.hpp>
  5. #include <glm/gtx/spline.hpp>
  6. namespace catmullRom
  7. {
  8. int test()
  9. {
  10. int Error(0);
  11. glm::vec2 Result2 = glm::catmullRom(
  12. glm::vec2(0.0f, 0.0f),
  13. glm::vec2(1.0f, 0.0f),
  14. glm::vec2(1.0f, 1.0f),
  15. glm::vec2(0.0f, 1.0f), 0.5f);
  16. glm::vec3 Result3 = glm::catmullRom(
  17. glm::vec3(0.0f, 0.0f, 0.0f),
  18. glm::vec3(1.0f, 0.0f, 0.0f),
  19. glm::vec3(1.0f, 1.0f, 0.0f),
  20. glm::vec3(0.0f, 1.0f, 0.0f), 0.5f);
  21. glm::vec4 Result4 = glm::catmullRom(
  22. glm::vec4(0.0f, 0.0f, 0.0f, 1.0f),
  23. glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
  24. glm::vec4(1.0f, 1.0f, 0.0f, 1.0f),
  25. glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f);
  26. return Error;
  27. }
  28. }//catmullRom
  29. namespace hermite
  30. {
  31. int test()
  32. {
  33. int Error(0);
  34. glm::vec2 Result2 = glm::hermite(
  35. glm::vec2(0.0f, 0.0f),
  36. glm::vec2(1.0f, 0.0f),
  37. glm::vec2(1.0f, 1.0f),
  38. glm::vec2(0.0f, 1.0f), 0.5f);
  39. glm::vec3 Result3 = glm::hermite(
  40. glm::vec3(0.0f, 0.0f, 0.0f),
  41. glm::vec3(1.0f, 0.0f, 0.0f),
  42. glm::vec3(1.0f, 1.0f, 0.0f),
  43. glm::vec3(0.0f, 1.0f, 0.0f), 0.5f);
  44. glm::vec4 Result4 = glm::hermite(
  45. glm::vec4(0.0f, 0.0f, 0.0f, 1.0f),
  46. glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
  47. glm::vec4(1.0f, 1.0f, 0.0f, 1.0f),
  48. glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f);
  49. return Error;
  50. }
  51. }//catmullRom
  52. namespace cubic
  53. {
  54. int test()
  55. {
  56. int Error(0);
  57. glm::vec2 Result2 = glm::cubic(
  58. glm::vec2(0.0f, 0.0f),
  59. glm::vec2(1.0f, 0.0f),
  60. glm::vec2(1.0f, 1.0f),
  61. glm::vec2(0.0f, 1.0f), 0.5f);
  62. glm::vec3 Result3 = glm::cubic(
  63. glm::vec3(0.0f, 0.0f, 0.0f),
  64. glm::vec3(1.0f, 0.0f, 0.0f),
  65. glm::vec3(1.0f, 1.0f, 0.0f),
  66. glm::vec3(0.0f, 1.0f, 0.0f), 0.5f);
  67. glm::vec4 Result = glm::cubic(
  68. glm::vec4(0.0f, 0.0f, 0.0f, 1.0f),
  69. glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
  70. glm::vec4(1.0f, 1.0f, 0.0f, 1.0f),
  71. glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f);
  72. return Error;
  73. }
  74. }//catmullRom
  75. int main()
  76. {
  77. int Error(0);
  78. Error += catmullRom::test();
  79. Error += hermite::test();
  80. Error += cubic::test();
  81. return Error;
  82. }