]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programdata.cpp
Throw an exception if there's too many uniforms in a ProgramData
[libs/gl.git] / source / programdata.cpp
index 1589d9b0d44e00258d2457fc1f8acb0def28b23e..4d8ca4dd1adabc338967ab91bc2e817091d18a49 100644 (file)
@@ -109,15 +109,16 @@ void ProgramData::uniform(const string &name, Uniform *uni)
        if(i>=0)
        {
                uniforms[i].replace_value(uni);
-
-               if(static_cast<unsigned>(i)<MASK_BITS)
-                       dirty |= 1<<i;
-               else  // Force a full update if the mask isn't wide enough
-                       dirty = ALL_ONES;
-
+               dirty |= 1<<i;
                return;
        }
 
+       if(uniforms.size()>=MASK_BITS)
+       {
+               delete uni;
+               throw too_many_uniforms(name);
+       }
+
        vector<NamedUniform>::iterator j = lower_bound(uniforms.begin(), uniforms.end(), name, uniform_name_compare);
 
        NamedUniform nu;
@@ -603,7 +604,16 @@ void ProgramData::apply() const
                {
                        unsigned required_size = last_block->get_required_buffer_size();
                        if(last_block->get_required_buffer_size()>buffer->get_size())
-                               buffer->data(required_size, 0);
+                       {
+                               if(buffer->get_size()>0)
+                               {
+                                       delete buffer;
+                                       buffer = new Buffer(UNIFORM_BUFFER);
+                                       last_block->change_buffer(buffer);
+                               }
+
+                               buffer->storage(required_size);
+                       }
                }
        }