]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/bufferable.cpp
Remove support for array size specialization from the engine as well
[libs/gl.git] / source / core / bufferable.cpp
index abbde26381019db839d0064bfdee1de83f889fbc..c312a4339a876f8436877842f44e689aa3f32b7a 100644 (file)
@@ -1,21 +1,13 @@
 #include <stdexcept>
 #include "buffer.h"
 #include "bufferable.h"
+#include "error.h"
 
 using namespace std;
 
 namespace Msp {
 namespace GL {
 
-Bufferable::Bufferable():
-       buffer(0),
-       offset(0),
-       next_in_buffer(0),
-       prev_in_buffer(0),
-       location_dirty(false),
-       dirty(false)
-{ }
-
 Bufferable::~Bufferable()
 {
        unlink_from_buffer();
@@ -61,18 +53,13 @@ void Bufferable::change_buffer(Buffer *buf)
        }
 }
 
-unsigned Bufferable::get_required_buffer_size() const
+size_t Bufferable::get_required_buffer_size() const
 {
        const Bufferable *last = this;
        for(; last->next_in_buffer; last=last->next_in_buffer) ;
        return last->offset+last->get_data_size();
 }
 
-Bufferable::AsyncUpdater *Bufferable::refresh_async() const
-{
-       return dirty ? new AsyncUpdater(*this) : 0;
-}
-
 void Bufferable::unlink_from_buffer()
 {
        if(prev_in_buffer)
@@ -90,11 +77,11 @@ void Bufferable::unlink_from_buffer()
 
 void Bufferable::update_offset()
 {
-       unsigned new_offset = 0;
+       size_t new_offset = 0;
        if(prev_in_buffer)
                new_offset = prev_in_buffer->offset+prev_in_buffer->get_data_size();
 
-       unsigned align = get_alignment();
+       size_t align = get_alignment();
        new_offset += align-1;
        new_offset -= new_offset%align;
        if(new_offset!=offset)
@@ -115,11 +102,13 @@ void Bufferable::update_offset()
 
 void Bufferable::upload_data(char *target) const
 {
-       unsigned data_size = get_data_size();
+       if(!buffer)
+               throw invalid_operation("Bufferable::upload_data");
+
+       size_t data_size = get_data_size();
        if(location_dirty)
        {
                buffer->require_size(offset+data_size);
-               location_changed(buffer, offset, data_size);
                location_dirty = false;
        }