X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbuffer.cpp;h=4a36937e7b745d1dd32f8c1e9ce19df0766037d7;hb=e98188ff6c9bba9761b71f2a69f3be7eb89ba3da;hp=523b737d32bf696ff3628e48ddd4b6b64e55f428;hpb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;p=libs%2Fgl.git diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 523b737d..4a36937e 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -8,7 +8,7 @@ using namespace std; namespace Msp { namespace GL { -void Buffer::storage(unsigned sz) +void Buffer::storage(size_t sz, BufferUsage u) { if(size>0) { @@ -20,6 +20,7 @@ void Buffer::storage(unsigned sz) throw invalid_argument("Buffer::storage"); size = sz; + usage = u; allocate(); } @@ -29,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>size || off+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