My question is regarding element array buffer (IBO) binding.
I have heard it said that (providing a VAO is already bound) an IBO binding will be saved to the current state of the VAO. Does this mean that instead of binding the IBO henceforth, we can just bind the VAO instead? i.e. as long as the VAO is bound before calling glDrawElements(), the draw call will always work?
I have provided an annotated code example below, for clarity:
// ...
// VBO:
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glNamedBufferData(VBO, sizeof(data), &data, draw_method)
// VAO:
glGenVertexArrays(1, VAO);
glBindVertexArray(VAO);
// Enable and input attributes etc...
// IBO:
glGenBuffers(1, IBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
glNamedBufferData(IBO, sizeof(data), &data, draw_method)
/* index buffer binding saved to VAO state?
as long as VAO is bound prior to draw call,
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO)
does not need to be called again? */
// ...
while (!display.WindowShouldClose())
{
display.ClearBuffers();
// ...
glBindVertexArray(VAO);
// index buffer binding not necessary? Only VAO binding required?
glDrawElements(GL_TRIANGLES, elements, GL_UNSIGNED_SHORT, nullptr);
// ...
display.SwapBuffers();
}