<p>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:</p>
<ul>
<li><code>glEnableVertexAttribArray</code></li>
<li><code>glDisableVertexAttribArray</code></li>
<li><code>glVertexAttribPointer</code></li>
<li><code>glBindBuffer(GL_ELEMENT_ARRAY_BUFFER)</code></li>
</ul>
<p>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.</p>

CC BY-SA 4.0
2020-07-17T19:18:57.557Z
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
CC BY-SA 4.0
2020-07-16T11:38:58.120Z
2020-07-16T14:47:20.923Z
2020-07-16T14:47:20.923Z
Reynolds
<p>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 <code>vao.unbind();</code>, it simply calls <code>glBindVertexArray(0);</code>.  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.</p>
<p>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?</p>
<p>With WebGL I'm seeing that it does not unbind the VBO when you unset the VAO, despite what <a href="https://www.reddit.com/r/opengl/comments/beioq1/do_you_need_to_also_unbind_the_vertex_buffer/" rel="nofollow noreferrer">this reddit post</a> is saying.</p>

<opengl><webgl><opengl-es>
When unsetting a VAO, should you also unbind the associated VBOs?
NateW
# When unsetting a VAO, should you also unbind the associated VBOs?

(Asked by: username_0 on 2020-07-16)

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](https://www.reddit.com/r/opengl/comments/beioq1/do_you_need_to_also_unbind_the_vertex_buffer/) is saying.

**Tags:** opengl, webgl, opengl-es


---

## 1 answers

### Answer by username_1 on 2020-07-16. Score: 2 | Accepted 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.

> **Comments:**
> **username_0**: 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.  

---

