ofBufferObject updateData Advice


I am working on a rendering system that uses a texture buffer and instanced rendering to render interleaved pngs with alpha in 3D space. Items that have the same shader are built up in a list and then rendered on a shader switch with

// for some reason I have to call mVboMesh.getVbo(); for it to update properly
mBufferObject.updateData( 0, mMatrices);
mVboMesh.drawInstanced( OF_MESH_FILL, mMatrixIndex );

Sometimes the list is thousands of objects, but sometimes it only renders a single item. Calling updateData is expensive to upload all the matrices to render only one object. What is the best way to upload only some of the data in the beginning? I noticed that the updateData has an offset argument, but I need a range, like 0->10 or something to update the first ‘n’ matrices.



you can call

mBufferObject.updateData(offset, bytes, data);

Thanks! Wasn’t sure you could just pass in bytes that was less than the total vector size. In this example mMatrixIndex is usually 30 and the size of the vector mMatrices is 256
mBufferObject.updateData(0, mMatrixIndex*sizeof(glm::mat4), &mMatrices[0] );
This seems to work.