Question on VAO/VBOs

Since the VAO needs to be completely setup during initialization, what is the best way to feed new vertex data to the GPU? Is it better to recreate the VAO and VBO or to simply pass new vertex and texture data to the VBO?

A VAO does not hold any data. You simply update your VBO once the VAO is bound. The VAO remains completely untouched by updates to the VBO’s data store.

Correct. If I have a function named fillVertexArray(), would all I need to do is bind the VBO, call glBufferData() and then unbind? Or is there a step missing?

When using vertex array objects you have to be certain that

a) you either update the buffer which is bound by the currently bound VAO
b) or you update the buffer while no VAO is bound at all, thus not altering the bindings of the currently bound VAO
c) or you you switch VAOs before updating the buffer you want

Action a) is preferable. Why? Because binding and unbinding costs time and if you can determine that a buffer needs to be updated shortly before you render from the currently bound buffer (and thus VAO), you don’t need to switch either of them.

[QUOTE=thokra;1247385]When using vertex array objects you have to be certain that

a) you either update the buffer which is bound by the currently bound VAO
b) or you update the buffer while no VAO is bound at all, thus not altering the bindings of the currently bound VAO
c) or you you switch VAOs before updating the buffer you want

Action a) is preferable. Why? Because binding and unbinding costs time and if you can determine that a buffer needs to be updated shortly before you render from the currently bound buffer (and thus VAO), you don’t need to switch either of them.[/QUOTE]

A) should work because right now I only have one VAO and one VBO. I wanted to reuse them for each object getting drawn but wasn’t sure if that was the best practice. If I can simply update the buffer only as needed then great!

IMHO, that is the way to go. The fewer unnecessary changes the better. However, buffer sizes should probably not exceed a few MB. Test various sizes until you reach max performance.

And just to make sure I have the correct understanding… in my data update function should I be using glBufferData() or look into the glMapBuffer() calls? I thought all I needed was a glBufferData() but that doesn’t seem to carry over to the actual rendering. I must be missing something…

How about glBufferSubData…??