3

Suppose I have 2 different objects, each one has its own VAO and draw call. Something like this:

void Object::Draw() {
    glBindVertexArray(vao);
    glDrawArrays(GL_TRIANGLES, foo, bar);
}

First I call the first object's draw call which binds its VAO and renders it. Then, I do the same thing for the second object.

I know this will work and both objects will be rendered. My question is why. What happens in OpenGL's state when I bind a VAO without unbinding any other previously bound VAOs?

Jean Catanho
  • 227
  • 5
  • 17
  • 1
    You never have to unbind anything in OpenGL (except you want nothing to be bound). Every binding method overrides the current state. – BDL Aug 11 '17 at 09:00

1 Answers1

3

Override.

If the bind is successful no change is made to the state of the vertex array object, and any previous vertex array object binding is broken.

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindVertexArray.xhtml

jparimaa
  • 1,816
  • 14
  • 18