+ buf_range(0)
+{
+ static Require _req(ARB_uniform_buffer_object);
+
+ if(!size)
+ throw invalid_argument("UniformBlock::UniformBlock");
+ data.resize(size);
+}
+
+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(char *target) const
+{
+ if(!buf_range)
+ buf_range = new BufferRange(*get_buffer(), get_offset(), size);
+
+ if(target)
+ copy(data.begin(), data.end(), target);
+ else
+ buf_range->data(&data[0]);
+}