From: Mikko Rasa Date: Sun, 15 Dec 2013 18:03:20 +0000 (+0200) Subject: Explicitly bind buffer in Bufferable::update_buffer X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5c51ba1057b222ab44eca253828d58e107e80df0;p=libs%2Fgl.git Explicitly bind buffer in Bufferable::update_buffer This reduces unnecessary bind/unbind thrashing if the buffer needs to be resized. --- diff --git a/source/bufferable.cpp b/source/bufferable.cpp index 60df3eec..1f6122e0 100644 --- a/source/bufferable.cpp +++ b/source/bufferable.cpp @@ -81,6 +81,8 @@ void Bufferable::update_offset() void Bufferable::update_buffer() const { + const Buffer *old_buffer = Buffer::current(buffer->get_type()); + buffer->bind(); if(offset+get_data_size()>=buffer->get_size()) { const Bufferable *last = this; @@ -100,6 +102,10 @@ void Bufferable::update_buffer() const } upload_data(); + if(old_buffer) + old_buffer->bind_to(buffer->get_type()); + else + buffer->unbind(); dirty = false; }