namespace Msp {
namespace GL {
+Bufferable::Bufferable(Bufferable &&other):
+ buffer(other.buffer),
+ offset(other.offset),
+ next_in_buffer(other.next_in_buffer),
+ prev_in_buffer(other.prev_in_buffer),
+ location_dirty(other.location_dirty),
+ dirty(other.dirty)
+{
+ other.buffer = 0;
+ other.next_in_buffer = 0;
+ other.prev_in_buffer = 0;
+ if(next_in_buffer)
+ next_in_buffer->prev_in_buffer = this;
+ if(prev_in_buffer)
+ prev_in_buffer->next_in_buffer = this;
+}
+
Bufferable::~Bufferable()
{
unlink_from_buffer();
}
}
-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)
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)
if(!buffer)
throw invalid_operation("Bufferable::upload_data");
- unsigned data_size = get_data_size();
+ size_t data_size = get_data_size();
if(location_dirty)
{
buffer->require_size(offset+data_size);