X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbuffer.cpp;h=ed0c552360ac8fad2345236e2024d17455200334;hb=6d2e2a0bb28496a8c25b441009bdd2a1a1e72d81;hp=811b3e41d7cbfb9ed16e613b29a7c28674d07659;hpb=160e9eea29bd10034733d59507fa1bcca36be401;p=libs%2Fgl.git diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 811b3e41..ed0c5523 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -8,11 +8,7 @@ using namespace std; namespace Msp { namespace GL { -Buffer::Buffer(): - size(0) -{ } - -void Buffer::storage(unsigned sz) +void Buffer::storage(size_t sz, BufferUsage u) { if(size>0) { @@ -24,6 +20,7 @@ void Buffer::storage(unsigned sz) throw invalid_argument("Buffer::storage"); size = sz; + usage = u; allocate(); } @@ -33,19 +30,39 @@ void Buffer::data(const void *d) return sub_data(0, size, d); } -void Buffer::sub_data(unsigned off, unsigned sz, const void *d) +void Buffer::sub_data(size_t off, size_t sz, const void *d) { if(size==0) throw invalid_operation("Buffer::sub_data"); + if(off>get_total_size() || off%size+sz>size) + throw out_of_range("Buffer::sub_data"); BufferBackend::sub_data(off, sz, d); } -void Buffer::require_size(unsigned req_sz) const +void Buffer::require_size(size_t req_sz) const { if(size