efficiently sending data to GPU

Hello,

I am currently working on my first marching cubes algorithm for terrain generation which works fine so far.

I had in mind to update only a few voxels of the terrain each frame so I would also need to update parts of the terrain each frame and send the changed vertices to my VBO.

I had in mind to use
glBufferSubData();

to only update certain parts of the mesh. The problem is that the areas that change are nor necessarily stored next to each other in the Array so I would have to call glBufferSubData(); multiple times for each part of the terrain that changed. I am not even sure that this would be possible so what would be the most efficient way of updating only the parts that changed in my VBO? I also tried to upload all the Vertices to the GPU each frame but that is really slow and not what I want.

Any Ideas and Hints welcome, thanks!

Using glBufferSubData several times to update more than one part of your buffer should work just fine. Another option would be to use glMapBuffer to directly access its content. However this is more tricky than it sounds, because you still need to write data in certain chunks (memcpy multiple of 64 bytes, if i am correct) for good speed. Haven’t used it in ages, so maybe someone else could give more insight about the possible pitfalls.

Jan.

An algorithmic idea, could be - if possible to predict future updates - to put the data to-be-updated in either separate “pages” (relative the static data), or even in a separate VBO, and (where needed) simply re-index the (parts of the) index buffer(s?) affected.

Yes, this is low-level memory management, LORD principle and possibly creating new collection algorithms to keep updates clustered, same as some databases does on updates. It again also reminds me why SGI became so good at handling large data sets.