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
)
glMapBuffer maps to the client's address space the entire data store of the buffer object currently bound to target . The data can then be directly read and/or written relative to the returned pointer, depending on the specified access policy.
The simplest method of updating VBO is copying again new data into the bound VBO with glBufferData() or glBufferSubData(). For this case, your application should have a valid vertex array all the time in your application.
Buffer Objects are OpenGL Objects that store an array of unformatted memory allocated by the OpenGL context (AKA the GPU). These can be used to store vertex data, pixel data retrieved from images or the framebuffer, and a variety of other things.
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/ )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With