X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Funiformblock.cpp;h=ff8033a0ffdd9d7ddaa270f1699307754b59b9da;hp=a87a6a42386ed39ee04b7368524796decd64ecfe;hb=HEAD;hpb=c21d4de686e7abd51b0a779af00f06ce459e18d6 diff --git a/source/uniformblock.cpp b/source/uniformblock.cpp deleted file mode 100644 index a87a6a42..00000000 --- a/source/uniformblock.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include "buffer.h" -#include "color.h" -#include "error.h" -#include "matrix.h" -#include "uniform.h" -#include "uniformblock.h" -#include "vector.h" - -using namespace std; - -namespace Msp { -namespace GL { - -UniformBlock::UniformBlock(): - buf_range(0) -{ } - -UniformBlock::UniformBlock(unsigned s): - size(s), - data(size), - buf_range(0) -{ } - -UniformBlock::~UniformBlock() -{ - delete buf_range; -} - -unsigned UniformBlock::get_alignment() const -{ - return BufferRange::get_uniform_buffer_alignment(); -} - -void UniformBlock::offset_changed() -{ - delete buf_range; - buf_range = 0; -} - -void UniformBlock::upload_data() const -{ - if(!buf_range) - buf_range = new BufferRange(*buffer, buffer_offset, size); - buf_range->data(&data[0]); -} - -void UniformBlock::attach(int index, const Uniform &uni) -{ - uniforms[index] = &uni; -} - -void UniformBlock::attach(const Program::UniformInfo &info, const Uniform &uni) -{ - uniforms[info.location] = &uni; - if(buffer) - { - uni.store(info, &data[info.location]); - dirty = true; - } -} - -void UniformBlock::apply(int index) const -{ - if((index>=0) != (buffer!=0)) - throw invalid_operation("UniformBlock::apply"); - - if(buffer) - { - if(dirty) - update_buffer_data(); - buf_range->bind_to(UNIFORM_BUFFER, index); - } - else - { - for(map::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - i->second->apply(i->first); - } -} - -} // namespace GL -} // namespace Msp