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.

124 lines
2.5 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/glm.hpp>
  3. /*
  4. #if GLM_CONFIG_SIMD == GLM_ENABLE
  5. #include <glm/gtx/common.hpp>
  6. #include <glm/gtc/integer.hpp>
  7. #include <glm/gtc/epsilon.hpp>
  8. #include <glm/gtc/type_aligned.hpp>
  9. #include <glm/ext/vector_relational.hpp>
  10. namespace glm
  11. {
  12. enum genTypeEnum
  13. {
  14. QUALIFIER_HIGHP,
  15. QUALIFIER_MEDIUMP,
  16. QUALIFIER_LOWP
  17. };
  18. template <typename genType>
  19. struct genTypeTrait
  20. {};
  21. template <length_t L, typename T>
  22. struct genTypeTrait<vec<L, T, aligned_highp> >
  23. {
  24. static const genTypeEnum GENTYPE = QUALIFIER_HIGHP;
  25. };
  26. template <length_t L, typename T>
  27. struct genTypeTrait<vec<L, T, aligned_mediump> >
  28. {
  29. static const genTypeEnum GENTYPE = QUALIFIER_MEDIUMP;
  30. };
  31. template <length_t L, typename T>
  32. struct genTypeTrait<vec<L, T, aligned_lowp> >
  33. {
  34. static const genTypeEnum GENTYPE = QUALIFIER_LOWP;
  35. };
  36. template<length_t L, typename T, qualifier Q, bool isAligned>
  37. struct load_gentype
  38. {
  39. };
  40. # if GLM_ARCH & GLM_ARCH_SSE_BIT
  41. template<qualifier Q>
  42. struct load_gentype<4, float, Q, true>
  43. {
  44. GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<4, float, Q> load(float const* Mem)
  45. {
  46. vec<4, float, Q> Result;
  47. Result.data = _mm_loadu_ps(Mem);
  48. return Result;
  49. }
  50. };
  51. # endif//GLM_ARCH & GLM_ARCH_SSE_BIT
  52. template<typename genType>
  53. GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType example_identity()
  54. {
  55. return detail::init_gentype<genType, detail::genTypeTrait<genType>::GENTYPE>::identity();
  56. }
  57. template <typename genType, typename valType>
  58. genType load(valType const* Mem)
  59. {
  60. }
  61. aligned_vec4 loadu(float const* Mem)
  62. {
  63. aligned_vec4 Result;
  64. # if GLM_ARCH & GLM_ARCH_SSE_BIT
  65. Result.data = _mm_loadu_ps(Mem);
  66. # else
  67. Result[0] = *(Mem + 0);
  68. Result[1] = *(Mem + 1);
  69. Result[2] = *(Mem + 2);
  70. Result[3] = *(Mem + 3);
  71. # endif//GLM_ARCH & GLM_ARCH_SSE_BIT
  72. return Result;
  73. }
  74. aligned_vec4 loada(float const* Mem)
  75. {
  76. aligned_vec4 Result;
  77. # if GLM_ARCH & GLM_ARCH_SSE_BIT
  78. Result.data = _mm_load_ps(Mem);
  79. # else
  80. Result[0] = *(Mem + 0);
  81. Result[1] = *(Mem + 1);
  82. Result[2] = *(Mem + 2);
  83. Result[3] = *(Mem + 3);
  84. # endif//GLM_ARCH & GLM_ARCH_SSE_BIT
  85. return Result;
  86. }
  87. }//namespace glm
  88. int test_vec4_load()
  89. {
  90. int Error = 0;
  91. float Data[] = {1.f, 2.f, 3.f, 4.f};
  92. glm::aligned_vec4 const V = glm::loadu(Data);
  93. Error += glm::all(glm::equal(V, glm::aligned_vec4(1.f, 2.f, 3.f, 4.f), glm::epsilon<float>())) ? 0 : 1;
  94. return Error;
  95. }
  96. #endif
  97. */
  98. int main()
  99. {
  100. int Error = 0;
  101. /*
  102. # if GLM_CONFIG_SIMD == GLM_ENABLE
  103. Error += test_vec4_load();
  104. # endif
  105. */
  106. return Error;
  107. }