summaryrefslogtreecommitdiff
path: root/lib/gl_traits.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-27 21:37:59 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-27 21:37:59 +0000
commitc00dacdb573d3e090a092e5725bb3eb7137d0098 (patch)
tree6f0b076b65e15dabd344954b9e3d20843689519a /lib/gl_traits.h
parentSupport constructing a glContainer from a collection of the same type (diff)
downloadilt-c00dacdb573d3e090a092e5725bb3eb7137d0098.tar.bz2
ilt-c00dacdb573d3e090a092e5725bb3eb7137d0098.tar.xz
ilt-c00dacdb573d3e090a092e5725bb3eb7137d0098.zip
Add traits vertex attrib func override for arrays
Address limitation on size when specifying arrays of glm::vec
Diffstat (limited to 'lib/gl_traits.h')
-rw-r--r--lib/gl_traits.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gl_traits.h b/lib/gl_traits.h
index 14ac9d8..b3c6909 100644
--- a/lib/gl_traits.h
+++ b/lib/gl_traits.h
@@ -83,6 +83,14 @@ template<> struct gl_traits<glm::uint32> : public gl_traits_integer {
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};
+ static constexpr auto vertexAttribFunc {
+ [](GLuint index, GLint, GLenum type, GLsizei stride, const void * pointer) -> GLuint {
+ const auto base = static_cast<const T *>(pointer);
+ for (GLuint e = 0; e < S; e++) {
+ glVertexAttribPointer(index + e, gl_traits<T>::size, type, GL_FALSE, stride, base + e);
+ }
+ return S;
+ }};
};
template<glm::length_t L, typename T, glm::qualifier Q> struct gl_traits<glm::vec<L, T, Q>> : public gl_traits<T> {