I have tried to look through lots of tutorials and online documentation about HOVs because they cost me a lot to understand them, but it seems impossible.
From what I understand, it is assumed that if you call glBindVertexArray, from there when you call the method glBindBuffer the associated buffer will be stored in the HOV. So if you do this:
glBindVertexArray(VAOs[0]);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_DYNAMIC_DRAW);
glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,2*sizeof(GLfloat),(void*)0);
Then from here every time you do this: Code glBindVertexArray (VAOs [0]);
Automatically it would be as if you were doing this: (Even if you do not "do it" because it's done, you only restore the buffer that is "done")
glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_DYNAMIC_DRAW);
glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,2*sizeof(GLfloat),(void*)0);
But when I do several VAOs and each VAO I put a VBO, for some reason when I put the first, second or third VAO and check what is the current VBO, I stay in the last VBO with which I call the glBindBuffer method . Why? I say something like this:
glBindVertexArray(VAOs[0]);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]);
glBindVertexArray(VAOs[1]);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[1]);
glBindVertexArray(VAOs[2]);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[2]);
glBindVertexArray(VAOs[0]);
GLint n;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &n);
std::cout << "VBO ACTUAL: " << n << std::endl;//Imprime VBOs[2] pero deberia imprimir VBOs[0]