diff options
| author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-04-01 14:24:09 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-04-01 14:24:09 +0100 |
| commit | e3e84d182d4d7ecffecf004f3cfd35f7b87df199 (patch) | |
| tree | 6c6859a9f5d6f8db3b96a85a51720ae642c9ab75 /gfx | |
| parent | Add helper to Decompose a member pointer (diff) | |
| download | ilt-e3e84d182d4d7ecffecf004f3cfd35f7b87df199.tar.bz2 ilt-e3e84d182d4d7ecffecf004f3cfd35f7b87df199.tar.xz ilt-e3e84d182d4d7ecffecf004f3cfd35f7b87df199.zip | |
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.
Diffstat (limited to 'gfx')
| -rw-r--r-- | gfx/gl/glVertexArray.h | 19 |
1 files 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<typename M, typename T> MP(M T::*) -> MP<M, T>; - explicit VertexArrayConfigurator(GLuint name) : name {name} { } VertexArrayConfigurator & @@ -52,7 +50,7 @@ namespace Impl { return addAttribsFor<VertexT>(divisor); } - template<typename VertexT, MP... Attribs> + template<typename VertexT, auto... Attribs> VertexArrayConfigurator & addAttribs(const GLuint divisor) { @@ -60,7 +58,7 @@ namespace Impl { return *this; } - template<typename VertexT, MP... Attribs> + template<typename VertexT, auto... Attribs> VertexArrayConfigurator & addAttribs(const GLuint divisor, const glBuffer & buffer) { @@ -68,7 +66,7 @@ namespace Impl { return addAttribs<VertexT, Attribs...>(divisor); } - template<typename VertexT, MP... Attribs> + template<typename VertexT, auto... Attribs> VertexArrayConfigurator & addAttribs(const GLuint divisor, glBuffer & buffer, const SequentialCollection<VertexT> auto & data) { @@ -93,14 +91,15 @@ namespace Impl { setPointerMeta(attrib + gl_traits<T>::vertexArrayAttribFormat(name, attrib, offset)); } - template<MP Attrib> + template<typename VertexT, auto Attrib> void setPointer() { - setPointer<typename decltype(Attrib)::ValueType>(Attrib); + using Mbr = MemberValueType<Attrib>; + setPointer<Mbr>(MP<Mbr, VertexT> {Attrib}); } - template<typename VertexT, MP... Attribs> + template<typename VertexT, auto... Attribs> void configureAttribs(const GLuint divisor) { @@ -108,7 +107,7 @@ namespace Impl { setPointer<VertexT>(0); } else { - ((setPointer<Attribs>()), ...); + ((setPointer<VertexT, Attribs>()), ...); } glVertexArrayBindingDivisor(name, binding++, divisor); } |
