diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 148c52c71..07e5b0dea 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -113,8 +113,6 @@ void Mesh::bindVAO(GLuint vao) { } void Mesh::bind() { - CORRADE_ASSERT((_vertexCount != 0) || !attributes.empty(), "Mesh: attributes are bound but vertex count is zero", ); - (this->*bindImplementation)(); } @@ -187,7 +185,9 @@ void Mesh::destroyImplementationVAO() { #endif } -void Mesh::attributePointerImplementationDefault(const Attribute&) {} +void Mesh::attributePointerImplementationDefault(const Attribute& attribute) { + attributes.push_back(attribute); +} void Mesh::attributePointerImplementationVAO(const Attribute& attribute) { bindVAO(vao); @@ -202,7 +202,9 @@ void Mesh::attributePointerImplementationDSA(const Attribute& attribute) { #endif #ifndef MAGNUM_TARGET_GLES2 -void Mesh::attributePointerImplementationDefault(const IntegerAttribute&) {} +void Mesh::attributePointerImplementationDefault(const IntegerAttribute& attribute) { + integerAttributes.push_back(attribute); +} void Mesh::attributePointerImplementationVAO(const IntegerAttribute& attribute) { bindVAO(vao); @@ -217,7 +219,9 @@ void Mesh::attributePointerImplementationDSA(const IntegerAttribute& attribute) #endif #ifndef MAGNUM_TARGET_GLES -void Mesh::attributePointerImplementationDefault(const LongAttribute&) {} +void Mesh::attributePointerImplementationDefault(const LongAttribute& attribute) { + longAttributes.push_back(attribute); +} void Mesh::attributePointerImplementationVAO(const LongAttribute& attribute) { bindVAO(vao); diff --git a/src/Mesh.h b/src/Mesh.h index efadddd73..b4313d2d9 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -678,8 +678,8 @@ class MAGNUM_EXPORT Mesh { inline void addInterleavedVertexBufferInternal(Buffer*, GLsizei, GLintptr) {} template inline void addVertexAttribute(typename std::enable_if::AttributeType, GLfloat>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { - for(GLuint i = 0; i != Implementation::Attribute::vectorCount(); ++i) { - attributes.push_back({ + for(GLuint i = 0; i != Implementation::Attribute::vectorCount(); ++i) + (this->*attributePointerImplementation)(Attribute{ buffer, location+i, Implementation::Attribute::components(attribute.dataOptions()), @@ -688,14 +688,11 @@ class MAGNUM_EXPORT Mesh { offset, stride }); - - (this->*attributePointerImplementation)(attributes.back()); - } } #ifndef MAGNUM_TARGET_GLES2 template inline void addVertexAttribute(typename std::enable_if::AttributeType>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { - integerAttributes.push_back({ + (this->*attributeIPointerImplementation)(IntegerAttribute{ buffer, location, Implementation::Attribute::components(), @@ -703,14 +700,12 @@ class MAGNUM_EXPORT Mesh { offset, stride }); - - (this->*attributeIPointerImplementation)(integerAttributes.back()); } #ifndef MAGNUM_TARGET_GLES template inline void addVertexAttribute(typename std::enable_if::AttributeType, GLdouble>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute& attribute, GLintptr offset, GLsizei stride) { - for(GLuint i = 0; i != Implementation::Attribute::vectorCount(); ++i) { - longAttributes.push_back({ + for(GLuint i = 0; i != Implementation::Attribute::vectorCount(); ++i) + (this->*attributeLPointerImplementation)(LongAttribute{ buffer, location+i, Implementation::Attribute::components(), @@ -718,9 +713,6 @@ class MAGNUM_EXPORT Mesh { offset, stride }); - - (this->*attributeLPointerImplementation)(longAttributes.back()); - } } #endif #endif