X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Funiformblock.cpp;h=498973f91de39dccf64512a00e0eceb1b3b2d63b;hb=9b2e1d2c6fe27574f10016b154dddad4f511996d;hp=a87a6a42386ed39ee04b7368524796decd64ecfe;hpb=c21d4de686e7abd51b0a779af00f06ce459e18d6;p=libs%2Fgl.git diff --git a/source/uniformblock.cpp b/source/uniformblock.cpp index a87a6a42..498973f9 100644 --- a/source/uniformblock.cpp +++ b/source/uniformblock.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include "buffer.h" #include "color.h" #include "error.h" @@ -14,13 +16,17 @@ namespace GL { UniformBlock::UniformBlock(): buf_range(0) -{ } +{ + static Require _req(ARB_shader_objects); +} UniformBlock::UniformBlock(unsigned s): size(s), data(size), buf_range(0) -{ } +{ + static Require _req(ARB_uniform_buffer_object); +} UniformBlock::~UniformBlock() { @@ -41,7 +47,7 @@ void UniformBlock::offset_changed() void UniformBlock::upload_data() const { if(!buf_range) - buf_range = new BufferRange(*buffer, buffer_offset, size); + buf_range = new BufferRange(*get_buffer(), get_offset(), size); buf_range->data(&data[0]); } @@ -53,7 +59,7 @@ void UniformBlock::attach(int index, const Uniform &uni) void UniformBlock::attach(const Program::UniformInfo &info, const Uniform &uni) { uniforms[info.location] = &uni; - if(buffer) + if(get_buffer()) { uni.store(info, &data[info.location]); dirty = true; @@ -62,13 +68,13 @@ void UniformBlock::attach(const Program::UniformInfo &info, const Uniform &uni) void UniformBlock::apply(int index) const { - if((index>=0) != (buffer!=0)) + if((index>=0) != (get_buffer()!=0)) throw invalid_operation("UniformBlock::apply"); - if(buffer) + if(get_buffer()) { if(dirty) - update_buffer_data(); + update_buffer(); buf_range->bind_to(UNIFORM_BUFFER, index); } else