]> git.tdb.fi Git - libs/gl.git/blobdiff - source/bufferable.cpp
Add support for multiple binding points in the RAII binders
[libs/gl.git] / source / bufferable.cpp
index 1f6122e0914561e91338a80650351ea48ae28306..eb3f1c006e925244f1c58ff671e4d28237378f4a 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdexcept>
+#include "bindable.h"
 #include "buffer.h"
 #include "bufferable.h"
 
@@ -81,8 +82,7 @@ void Bufferable::update_offset()
 
 void Bufferable::update_buffer() const
 {
-       const Buffer *old_buffer = Buffer::current(buffer->get_type());
-       buffer->bind();
+       BindRestore bind(buffer, buffer->get_type());
        if(offset+get_data_size()>=buffer->get_size())
        {
                const Bufferable *last = this;
@@ -102,10 +102,6 @@ void Bufferable::update_buffer() const
        }
 
        upload_data();
-       if(old_buffer)
-               old_buffer->bind_to(buffer->get_type());
-       else
-               buffer->unbind();
        dirty = false;
 }