# When unsetting a VAO, should you also unbind the associated VBOs?

I'm working with a js/wasm/c++ program that uses object oriented programming when updating the OpenGL state. There are corresponding c++ classes for VBOs (vertex buffer) and VAOs (vertex array). When we call vao.unbind();, it simply calls glBindVertexArray(0);. I'm seeing that unbinding the VAO does not unbind the corresponding VBOs. One of the VAO's VBOs was still set as ARRAY_BUFFER_BINDING target.

My question is: is it best practice to automatically unset the associated VBOs when you unset the VAO? Or should I write a separate function that unsets the VAO's VBOs?

With WebGL I'm seeing that it does not unbind the VBO when you unset the VAO, despite what this reddit post is saying.

## 1 Answer

No, you do not need to unbind the VBO's. VBO's are only added to the state of the VAO when that VAO is bound. So any previously bound VBO's will not alter the state of the VAO that you are going to bind. The state of a bound VAO can be changed with the following calls:

• glEnableVertexAttribArray
• glDisableVertexAttribArray
• glVertexAttribPointer
• glBindBuffer(GL_ELEMENT_ARRAY_BUFFER)

You can bind and unbind VBO's without a currently bound VAO and even share them amongst VAO's. The VBO is simply a pointer to a data container that can be used for multiple purposes.

• Thank you for the feedback! – NateW Jul 16 at 14:43
• Just as an update for future readers. For my project we wanted to keep a pristine GL state whenever we did an operation. So, it was surprising to us that when you bind a VAO, it binds the associated VBOs but when you unbind a VAO, it doesn't unbind the associated VBOs. So for our project, our VAO class automatically unbinds the VBOs when the VAO was unbound. – NateW Jul 17 at 19:18