From 0c4d433f70d6d6e019874f835d0db5faff8d8dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 20 Jan 2013 21:28:29 +0100 Subject: [PATCH] Quick dirty fix for element array buffer binding in VAOs. If no DSA is available and element array buffer was bound previously (e.g. because data were uploaded to it), after binding VAO the binding point is apparently reset to 0. But our state tracking thinks that the buffer is still bound and thus doesn't bind it explicitly again when asked for it. It causes crash in the driver, because it tries to read from zero adress in client memory instead of bound buffer. Needs to be solved properly, when I found out an clean solution. --- src/Mesh.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 4b4da14da..e23f5418b 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -20,6 +20,7 @@ #include "Buffer.h" #include "Context.h" #include "Extensions.h" +#include "Implementation/BufferState.h" #include "Implementation/MeshState.h" #include "Implementation/State.h" @@ -244,6 +245,11 @@ void Mesh::bindIndexBufferImplementationDefault(Buffer* buffer) { void Mesh::bindIndexBufferImplementationVAO(Buffer* buffer) { bindVAO(vao); + + /* Reset ElementArray binding to force explicit glBindBuffer call later */ + /** @todo Do this cleaner way */ + Context::current()->state()->buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::Target::ElementArray)] = 0; + buffer->bind(Buffer::Target::ElementArray); }