]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/buffer.cpp
Add a usage parameter to Buffer
[libs/gl.git] / source / core / buffer.cpp
index 557e576d2ac929e256646c0a3cdc59bd3887a962..15a37397bcb18bdf094b5e5a5cef1a7d31b38c31 100644 (file)
@@ -8,7 +8,7 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-void Buffer::storage(size_t sz)
+void Buffer::storage(size_t sz, BufferUsage u)
 {
        if(size>0)
        {
@@ -20,6 +20,7 @@ void Buffer::storage(size_t sz)
                throw invalid_argument("Buffer::storage");
 
        size = sz;
+       usage = u;
 
        allocate();
 }
@@ -33,6 +34,8 @@ 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);
 }