I want to update an object's list of vertices after a VBO has been created. I've seen both glBufferSubData
and glMapBuffer
and they both appear to do similar things, which means I'm now unsure which one to use.
My pseudo workflow is:
Create object
Begin vertex update (calls glBufferData with data = nullptr)
Update object's vertices
End vertex update (takes the updated vertices and either callsglBufferSubData
orglMapBuffer
)
Both work.
If you intend to update the vertices often (every frame or so), I recommend avoiding glBufferSubData, which requires one more memcpy in the driver. glMapBuffer/glMapBufferRange usually gets you more perf.
If you update only rarely, glBufferSubData will do fine.
See also chapter 28 of OpenGL Insights ( free : http://openglinsights.com/ )