I was going over my render method and I started thinking. Do I need a VAO? All the tutorials I have looked at go over VAOs, but do I need them if my data is dynamic (changing every frame)?
I understand that VAO is a state object that is s supposed to hold the ‘state’ of Vertex Array Pointers for the VBOs I bind and etc. That if I bind a VAO and then use glEnableAttribPointer, bind a VBO, and glVertexAttribPointer to pointer to the VBO data a record is saved into the VAO. Where I can call the VAO bind function in my render method and everything will know how to draw.
But my confusion kind of comes in when the data I’m using is dynamic and changing every frame. If I have my render method as:
public void render()
{
//Use the shader program
glUseProgram(shaderProgramHandle);
//Get the Uniform for the MVP shader
glUniformMatrix4(matrixBufferHandle, false, mvpBuffer);
//Enable the VAO and its attributes
glBindVertexArray(vertexArrayHandle); //Can comment out and has no effect; Never bound until this point
glEnableVertexAttribArray(0);
//Bind the Vertex Buffer and indicate where the Vertex are
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferHandle);
glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
//glDrawArrays(GL_TRIANGLES, 0, 3);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferHandle);
GL11.glDrawElements(GL_TRIANGLES, indexDrawCount, GL11.GL_UNSIGNED_INT, 0);
glDisableVertexAttribArray(0);
}
Do I really need the VAO? Would my app be faster with out them or with them? Or am I doing a bad ‘thing’ rebinding all the Vertex Attributes and etc every single time my render method is called? Should I only be rebinding the VAO, does this change (The rebinding) if my data is dynamic?