From 8538610fa27e1db37070eaabe34f1e4e41648bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 1 Apr 2024 17:48:45 +0200 Subject: [PATCH] GL: reset state tracker buffer binding after a base/range unbind. Should have been done in 8f6f4053fcd7893511a748df35e9cda881d390bf already, but wasn't. The test extended in previous commit now passes. --- src/Magnum/GL/Buffer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Magnum/GL/Buffer.cpp b/src/Magnum/GL/Buffer.cpp index e5793835b..bee55e10f 100644 --- a/src/Magnum/GL/Buffer.cpp +++ b/src/Magnum/GL/Buffer.cpp @@ -145,6 +145,14 @@ Int Buffer::maxUniformBindings() { } void Buffer::unbind(const Target target, const UnsignedInt index) { + /* Inverse of what's in bind(Target, UnsignedInt, GLintptr, GLsizeiptr) + below -- unbinding a buffer via glBindBufferBase() / glBindBufferRange() + also unbinds it from the "regular" binding target as a side effect. */ + Context::current().state().buffer.bindings[Implementation::BufferState::indexForTarget( + /* The Target enum is a subset of TargetHint and the values match, so + no expensive translation is necessary */ + TargetHint(UnsignedInt(target)))] = 0; + glBindBufferBase(GLenum(target), index, 0); }