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.
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.
Correct answer by Reynolds on August 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP