]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programdata.cpp
Buffer fixes in ProgramData
[libs/gl.git] / source / programdata.cpp
index b8a272c0fc0bde8a3699a81e347115327c41938f..f3f498f3e948966d9e1dd3524175b1d0ddc5060e 100644 (file)
@@ -39,6 +39,7 @@ ProgramData::~ProgramData()
                delete i->second;
        for(BlockMap::iterator i=blocks.begin(); i!=blocks.end(); ++i)
                delete i->second.block;
+       delete buffer;
 }
 
 void ProgramData::uniform(const string &name, Uniform *uni)
@@ -46,6 +47,9 @@ void ProgramData::uniform(const string &name, Uniform *uni)
        UniformMap::iterator i = uniforms.find(name);
        if(i!=uniforms.end())
        {
+               /* UniformBlock does not copy the uniforms, so existing blocks will be
+               left with stale pointers.  This is not a problem as long as no one stores
+               pointers to the blocks and expects them to stay valid. */
                delete i->second;
                i->second = uni;
                changes = VALUES_CHANGED;
@@ -168,7 +172,10 @@ UniformBlock *ProgramData::create_block(const Program::UniformBlockInfo &info) c
 {
        UniformBlock *block = new UniformBlock(info.data_size);
        if(!buffer)
+       {
                buffer = new Buffer(UNIFORM_BUFFER);
+               buffer->set_usage(STREAM_DRAW);
+       }
        block->use_buffer(buffer, last_block);
        last_block = block;
        return block;