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

Computer Graphics Asked by NateW on August 27, 2021

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.

One 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

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.

Correct answer by Reynolds on August 27, 2021

Add your own answers!

Related Questions

glutSolid* source code

1  Asked on November 22, 2021 by tado-mi


How to retrieve data from Compute Shader to CPU?

0  Asked on November 15, 2021 by ethan-ma


unwanted patterns in simplex noise

1  Asked on November 13, 2021 by sam-apostel


Procedural generation of biological models

1  Asked on November 13, 2021 by daniel-cooke


What method is used for baking grayscale curvature maps

1  Asked on November 10, 2021 by jummit


Why are texture coordinates often called UVs?

2  Asked on August 27, 2021 by samanthaj


Dynamic Ray-Triangle Intersection

1  Asked on August 27, 2021 by cemklkn


Draw Line on Arbitrary Surface

0  Asked on August 27, 2021 by valentin-molina


How to raytrace Bezier surfaces?

5  Asked on August 27, 2021 by luser-droog


Better Shadow Mapping Techniques

2  Asked on August 27, 2021 by arjan-singh


What does GPU assembly look like?

4  Asked on August 27, 2021 by sebastien-finor


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir