summaryrefslogtreecommitdiff
path: root/lib/gl_traits.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-13 23:06:39 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-13 23:06:39 +0100
commit1c8e84d9503237e7a308107a0a44fbc7f188c700 (patch)
tree60e80d7f4e91621bc62cb5fb2f6c61aae631b4d9 /lib/gl_traits.hpp
parentLoad assimp textures in parallel (diff)
parentFix typo in name SceneCPtr (diff)
downloadilt-1c8e84d9503237e7a308107a0a44fbc7f188c700.tar.bz2
ilt-1c8e84d9503237e7a308107a0a44fbc7f188c700.tar.xz
ilt-1c8e84d9503237e7a308107a0a44fbc7f188c700.zip
Merge branch 'materials' into assimp
Diffstat (limited to 'lib/gl_traits.hpp')
-rw-r--r--lib/gl_traits.hpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/lib/gl_traits.hpp b/lib/gl_traits.hpp
index d140de9..e2e689d 100644
--- a/lib/gl_traits.hpp
+++ b/lib/gl_traits.hpp
@@ -6,37 +6,50 @@
#include <glm/fwd.hpp>
template<typename T> struct gl_traits;
-template<> struct gl_traits<glm::f32> {
- static constexpr GLenum type {GL_FLOAT};
+struct gl_traits_base {
static constexpr GLint size {1};
};
-template<> struct gl_traits<glm::f64> {
+struct gl_traits_float : public gl_traits_base {
+ static constexpr auto vertexAttribFunc {
+ [](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
+ glVertexAttribPointer(index, size, type, GL_FALSE, stride, pointer);
+ }};
+};
+struct gl_traits_longfloat : public gl_traits_base {
+ static constexpr auto vertexAttribFunc {
+ [](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
+ glVertexAttribLPointer(index, size, type, stride, pointer);
+ }};
+};
+struct gl_traits_integer : public gl_traits_base {
+ static constexpr auto vertexAttribFunc {
+ [](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
+ glVertexAttribIPointer(index, size, type, stride, pointer);
+ }};
+};
+template<> struct gl_traits<glm::f32> : public gl_traits_float {
+ static constexpr GLenum type {GL_FLOAT};
+};
+template<> struct gl_traits<glm::f64> : public gl_traits_longfloat {
static constexpr GLenum type {GL_DOUBLE};
- static constexpr GLint size {1};
};
-template<> struct gl_traits<glm::int8> {
+template<> struct gl_traits<glm::int8> : public gl_traits_integer {
static constexpr GLenum type {GL_BYTE};
- static constexpr GLint size {1};
};
-template<> struct gl_traits<glm::int16> {
+template<> struct gl_traits<glm::int16> : public gl_traits_integer {
static constexpr GLenum type {GL_SHORT};
- static constexpr GLint size {1};
};
-template<> struct gl_traits<glm::int32> {
+template<> struct gl_traits<glm::int32> : public gl_traits_integer {
static constexpr GLenum type {GL_INT};
- static constexpr GLint size {1};
};
-template<> struct gl_traits<glm::uint8> {
+template<> struct gl_traits<glm::uint8> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_BYTE};
- static constexpr GLint size {1};
};
-template<> struct gl_traits<glm::uint16> {
+template<> struct gl_traits<glm::uint16> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_SHORT};
- static constexpr GLint size {1};
};
-template<> struct gl_traits<glm::uint32> {
+template<> struct gl_traits<glm::uint32> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_INT};
- static constexpr GLint size {1};
};
template<typename T, std::size_t S> struct gl_traits<std::array<T, S>> : public gl_traits<T> {