From e3e84d182d4d7ecffecf004f3cfd35f7b87df199 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 1 Apr 2026 14:24:09 +0100 Subject: Fix VertexArrayConfigurator with derived classes Fixing passing a pointer to member of base class; previously the offset was deduced relative to the structure it was in, not the vertex as a whole. --- gfx/gl/glVertexArray.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gfx/gl/glVertexArray.h b/gfx/gl/glVertexArray.h index 323303c..4e8113f 100644 --- a/gfx/gl/glVertexArray.h +++ b/gfx/gl/glVertexArray.h @@ -4,6 +4,7 @@ #include "glArrays.h" #include "glBuffer.h" #include "gl_traits.h" +#include "util.h" namespace Impl { class VertexArrayConfigurator { @@ -20,11 +21,8 @@ namespace Impl { } M T::* ptr; - using ValueType = M; }; - template MP(M T::*) -> MP; - explicit VertexArrayConfigurator(GLuint name) : name {name} { } VertexArrayConfigurator & @@ -52,7 +50,7 @@ namespace Impl { return addAttribsFor(divisor); } - template + template VertexArrayConfigurator & addAttribs(const GLuint divisor) { @@ -60,7 +58,7 @@ namespace Impl { return *this; } - template + template VertexArrayConfigurator & addAttribs(const GLuint divisor, const glBuffer & buffer) { @@ -68,7 +66,7 @@ namespace Impl { return addAttribs(divisor); } - template + template VertexArrayConfigurator & addAttribs(const GLuint divisor, glBuffer & buffer, const SequentialCollection auto & data) { @@ -93,14 +91,15 @@ namespace Impl { setPointerMeta(attrib + gl_traits::vertexArrayAttribFormat(name, attrib, offset)); } - template + template void setPointer() { - setPointer(Attrib); + using Mbr = MemberValueType; + setPointer(MP {Attrib}); } - template + template void configureAttribs(const GLuint divisor) { @@ -108,7 +107,7 @@ namespace Impl { setPointer(0); } else { - ((setPointer()), ...); + ((setPointer()), ...); } glVertexArrayBindingDivisor(name, binding++, divisor); } -- cgit v1.3