]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/uniformblock.cpp
Split reflection data from Program to a separate struct
[libs/gl.git] / source / core / uniformblock.cpp
index 59871cdde8249b3b90e0dd03a89db66963e2efd6..4b07241fab3943d14f35932ea498024bdc5ad2d2 100644 (file)
@@ -20,7 +20,7 @@ DefaultUniformBlock::DefaultUniformBlock()
        static Require _req(ARB_shader_objects);
 }
 
-void DefaultUniformBlock::attach(const Program::UniformInfo &info, const Uniform &uni)
+void DefaultUniformBlock::attach(const ReflectData::UniformInfo &info, const Uniform &uni)
 {
        if(info.block->bind_point>=0)
                throw invalid_argument("DefaultUniformBlock::attach");
@@ -38,11 +38,8 @@ void DefaultUniformBlock::attach(int index, const Uniform &uni)
        uniforms[index] = &uni;
 }
 
-void DefaultUniformBlock::apply(int index) const
+void DefaultUniformBlock::apply() const
 {
-       if(index>=0)
-               throw invalid_argument("DefaultUniformBlock::apply");
-
        for(unsigned i=0; i<uniforms.size(); ++i)
                if(uniforms[i])
                        uniforms[i]->apply(i);
@@ -51,8 +48,7 @@ void DefaultUniformBlock::apply(int index) const
 
 BufferBackedUniformBlock::BufferBackedUniformBlock(unsigned s):
        size(s),
-       data(size),
-       buf_range(0)
+       data(size)
 {
        static Require _req(ARB_shader_objects);
        static Require _req2(ARB_uniform_buffer_object);
@@ -61,23 +57,12 @@ BufferBackedUniformBlock::BufferBackedUniformBlock(unsigned s):
                throw invalid_argument("BufferBackedUniformBlock::BufferBackedUniformBlock");
 }
 
-BufferBackedUniformBlock::~BufferBackedUniformBlock()
-{
-       delete buf_range;
-}
-
 unsigned BufferBackedUniformBlock::get_alignment() const
 {
        return Limits::get_global().uniform_buffer_alignment;
 }
 
-void BufferBackedUniformBlock::location_changed(Buffer *buf, unsigned off, unsigned) const
-{
-       delete buf_range;
-       buf_range = buf->create_range(off, size);
-}
-
-void BufferBackedUniformBlock::attach(const Program::UniformInfo &info, const Uniform &uni)
+void BufferBackedUniformBlock::attach(const ReflectData::UniformInfo &info, const Uniform &uni)
 {
        if(info.block->bind_point<0)
                throw invalid_argument("BufferBackedUniformBlock::attach");
@@ -86,16 +71,5 @@ void BufferBackedUniformBlock::attach(const Program::UniformInfo &info, const Un
        dirty = true;
 }
 
-void BufferBackedUniformBlock::apply(int index) const
-{
-       if(index<0)
-               throw invalid_argument("BufferBackedUniformBlock::apply");
-       if(!get_buffer())
-               throw invalid_operation("UniformBlock::apply");
-
-       refresh();
-       buf_range->bind_to(UNIFORM_BUFFER, index);
-}
-
 } // namespace GL
 } // namespace Msp