7 #include "uniformblock.h"
15 UniformBlock::UniformBlock():
19 UniformBlock::UniformBlock(unsigned s):
25 UniformBlock::~UniformBlock()
30 unsigned UniformBlock::get_alignment() const
32 return BufferRange::get_uniform_buffer_alignment();
35 void UniformBlock::offset_changed()
41 void UniformBlock::upload_data() const
44 buf_range = new BufferRange(*get_buffer(), get_offset(), size);
45 buf_range->data(&data[0]);
48 void UniformBlock::attach(int index, const Uniform &uni)
50 uniforms[index] = &uni;
53 void UniformBlock::attach(const Program::UniformInfo &info, const Uniform &uni)
55 uniforms[info.location] = &uni;
58 uni.store(info, &data[info.location]);
63 void UniformBlock::apply(int index) const
65 if((index>=0) != (get_buffer()!=0))
66 throw invalid_operation("UniformBlock::apply");
72 buf_range->bind_to(UNIFORM_BUFFER, index);
76 for(map<int, const Uniform *>::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
77 i->second->apply(i->first);