From 927561300670d08857546163ae79c94bf188de51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 4 Jun 2018 20:12:08 +0200 Subject: [PATCH] GL: properly reset vertex divisor after drawing w/o a VAO. Otherwise it messes up subsequent draws. --- doc/changelog.dox | 3 +++ src/Magnum/GL/Mesh.cpp | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 02ead06db..758ba1de7 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -98,6 +98,9 @@ See also: due to a pointer not being properly initialized after the @ref Platform::GlfwApplication::GLConfiguration "GLConfiguration" rework in 2018.04 (see [mosra/magnum#246](https://github.com/mosra/magnum/pull/246)) +- Vertex attribute divisor in @ref GL::Mesh::addVertexBufferInstanced() was + not properly cleaned up after when @gl_extension{ARB,vertex_array_object} + was disabled, causing subsequent draws to misbehave @subsection changelog-latest-deprecated Deprecated APIs diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index 7797e7342..3b0dad175 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -746,8 +746,18 @@ void Mesh::bindImplementationVAO() { } void Mesh::unbindImplementationDefault() { - for(const AttributeLayout& attribute: *reinterpret_cast*>(&_attributes)) + for(const AttributeLayout& attribute: *reinterpret_cast*>(&_attributes)) { glDisableVertexAttribArray(attribute.location); + + /* Reset also the divisor back so it doesn't affect */ + if(attribute.divisor) { + #ifndef MAGNUM_TARGET_GLES2 + glVertexAttribDivisor(attribute.location, 0); + #else + (this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, 0); + #endif + } + } } void Mesh::unbindImplementationVAO() {}