[ACCEPTED]-OpenGL VBO updating data-vbo

Accepted answer
Score: 10

There is another option, which is a bit 17 like option 3 - use one big VBO (probably 16 with GL_STREAM_DRAW mode) that is reset each frame (by 15 calling glBufferData with a NULL buffer pointer and the 14 same size each time) then glMapBuffer-ed right away. The 13 buffer is left mapped as it is filled in, then 12 unmapped just before drawing. Repeat.

The 11 call to glBufferData tells OpenGL that the old buffer 10 contents aren't needed, so the glMapBuffer doesn't 9 have to potentially wait to ensure the GPU 8 is finished with by the GPU.

This approach 7 seems to be the one officially sanctioned 6 by the vertex_buffer_object extension. See the "Vertex 5 arrays using a mapped buffer object" example:

http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt

This 4 suggests that OpenGL (or the driver?) will 3 be watching for this sort of behaviour, and 2 (when spotted) arrange things so that it 1 is performed efficiently.

Score: 2
  1. Doesn't sound like a good idea: it forces you to draw it in several calls while changing the bound buffer between each draw call.
  2. Might do the trick if your buffer is huge.
  3. The whole buffer will certainly be uploaded to the GPU. This will certainly be as efficient as one glBufferData, but you can do it asynchronously.

If think that glBufferData or glMapBuffer 3 are the better solution if your buffer is 2 small. 100000 * sizeof(float) * 3 ~= 1MB. There should be no problem with 1 that.

More Related questions