X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fbuffer.cpp;h=5b3339a1d66721c51d417494ab77f80c6a58d78c;hp=98625b813bdfd9a626d8be87f52e6a2d7db228d6;hb=2d3113a7dbbe4be2f1d1e8980c1c4e42175163da;hpb=1c2c36f1342df84ff195d8c58347c5e875590e0e diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 98625b81..5b3339a1 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -2,8 +2,10 @@ #include #include #include +#include #include #include "buffer.h" +#include "deviceinfo.h" #include "error.h" #include "misc.h" #include "vertexsetup.h" @@ -49,7 +51,11 @@ void Buffer::require_buffer_type(BufferType type) void Buffer::storage(unsigned sz) { if(size>0) - throw invalid_operation("Buffer::storage"); + { + if(sz!=size) + throw incompatible_data("Buffer::storage"); + return; + } if(sz==0) throw invalid_argument("Buffer::storage"); @@ -233,6 +239,16 @@ bool Buffer::set_current(BufferType type, const Buffer *buf) return true; } +void Buffer::set_debug_name(const string &name) +{ +#ifdef DEBUG + if(KHR_debug) + glObjectLabel(GL_BUFFER, id, name.size(), name.c_str()); +#else + (void)name; +#endif +} + vector BufferRange::bound_uniform; @@ -282,7 +298,7 @@ const BufferRange *&BufferRange::binding(BufferType type, unsigned index) { if(type==UNIFORM_BUFFER) { - if(index>=get_n_uniform_buffer_bindings()) + if(index>=Limits::get_global().max_uniform_bindings) throw out_of_range("BufferRange::binding"); if(bound_uniform.size()<=index) bound_uniform.resize(index+1); @@ -304,14 +320,12 @@ bool BufferRange::set_current(BufferType type, unsigned index, const BufferRange unsigned BufferRange::get_n_uniform_buffer_bindings() { - static unsigned count = get_i(GL_MAX_UNIFORM_BUFFER_BINDINGS); - return count; + return Limits::get_global().max_uniform_bindings; } unsigned BufferRange::get_uniform_buffer_alignment() { - static unsigned align = get_i(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT); - return align; + return Limits::get_global().uniform_buffer_alignment; } } // namespace GL