diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-01-02 15:05:21 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-01-02 15:05:21 +0000 |
commit | 5a0ecd5c4f0d286926cc333d3c30d5e2df07c883 (patch) | |
tree | ec96500639c16c8271602fdb051968683b0281e2 /lib | |
parent | Add a concept for sequential collections suitable for passing to OpenGL (diff) | |
download | ilt-5a0ecd5c4f0d286926cc333d3c30d5e2df07c883.tar.bz2 ilt-5a0ecd5c4f0d286926cc333d3c30d5e2df07c883.tar.xz ilt-5a0ecd5c4f0d286926cc333d3c30d5e2df07c883.zip |
Add a traits struct to lookup sizes/type enums for passing to OpenGL
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gl_traits.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/gl_traits.hpp b/lib/gl_traits.hpp new file mode 100644 index 0000000..b50ec50 --- /dev/null +++ b/lib/gl_traits.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include <GL/glew.h> +#include <array> +#include <glm/common.hpp> + +template<typename T> struct gl_traits; +template<> struct gl_traits<float> { + static constexpr GLenum type {GL_FLOAT}; + static constexpr GLint size {1}; +}; + +template<typename T, std::size_t S> struct gl_traits<std::array<T, S>> : public gl_traits<T> { + static constexpr GLint size {S * gl_traits<T>::size}; +}; + +template<glm::length_t L, typename T, glm::qualifier Q> struct gl_traits<glm::vec<L, T, Q>> : public gl_traits<T> { + static constexpr GLint size {L}; +}; + +template<glm::length_t C, glm::length_t R, typename T, glm::qualifier Q> +struct gl_traits<glm::mat<C, R, T, Q>> : public gl_traits<T> { + static constexpr GLint size {C * R}; +}; |