1
votes

After doing some basic tests, a few things stay unclear to me:

  • While you're initializing your application does the order in which you bind a vao, vbo and ibo matter? From most tutorials i have seen you generate the vao first then the vbo and then the ibo but in others they changed the order and it seemed to work...

  • How does the vao know what is being bind to it? Do you call some special function(behind the scenes) when calling glBindBuffer to the active vao object?

I'm not only asking "how" they work but also "why" they work, I've tried reading some of the openGL specifications but it was too confusing for a novice openGL programmer.

1
You should probably learn how objects in OpenGL work. Once you understand that, you can understand what it means for a VAO to store certain state.Nicol Bolas
@NicolBolas Thanks a lot, that cleared up some things for me! One thing stays unclear after reading "Vertex array objects" : say i have a program with a class with a render code: do i have to call glEnableVertexAttribArray(0); each render loop or does it remember that from the previous function?Anton D
By way of analogy, your "class with a render code" will remember which VAO it stores, right? VAOs are no different. As the page stated, every function on that page modifies the currently bound VAO (unless otherwise stated). If it were a C++ API, they'd be member functions of the VAO class.Nicol Bolas
@NicolBolas Ok, thanks a lot, how do accept this side answer as "solved"?Anton D
Telling you where to find the answer isn't itself an answer. That's why I posted it as a comment. But you can answer the question yourself with your current understanding of how these things work.Nicol Bolas

1 Answers

1
votes

Opengl is a state macine : when you call glBindVertexArray, it tells to opengl that it's this vao that is active, and thus, it's to this vao that the vbos will be bound. Then you have to recall glBindVertexArray with another vao index to change the active vao, and then bind another vbo to it.