]> git.tdb.fi Git - libs/gl.git/commitdiff
Explicitly bind buffer in Bufferable::update_buffer
authorMikko Rasa <tdb@tdb.fi>
Sun, 15 Dec 2013 18:03:20 +0000 (20:03 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 16 Dec 2013 18:28:43 +0000 (20:28 +0200)
This reduces unnecessary bind/unbind thrashing if the buffer needs to be
resized.

source/bufferable.cpp

index 60df3eec92c1bd188dbab825e998baf1dd97e7b4..1f6122e0914561e91338a80650351ea48ae28306 100644 (file)
@@ -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;
 }