From d42fdf115dfd6f3e5e2f83f2c2f905fb02fc1af4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 28 Sep 2014 20:52:17 +0300 Subject: [PATCH] Don't consider the current buffer in deciding whether to bind BufferRange glBindBufferRange should only be called if the buffer range bound to that index was changed. The buffer binding gets changed as a side-effect, but should not factor into the decision. --- source/buffer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/buffer.cpp b/source/buffer.cpp index 93ef98db..066ab96c 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -160,9 +160,12 @@ void BufferRange::bind_to(BufferType t, unsigned i) { if(t!=buffer.type) Buffer::require_buffer_type(t); - // Intentionally using bitwise | to avoid short-circuiting - if(Buffer::set_current(t, &buffer) | set_current(t, i, this)) + if(set_current(t, i, this)) + { + // The buffer gets bound as a side effect + Buffer::set_current(t, &buffer); glBindBufferRange(t, i, buffer.id, offset, size); + } } void BufferRange::unbind_from(BufferType t, unsigned i) -- 2.43.0