[SOLVED] VertexArrayObject actually change vertex attrib array state.

(repost from openGl forum https://www.opengl.org/discussion_boards/showthread.php/182706-VertexArrayObject-actually-change-vertex-attrib-array-state?p=1254828#post1254828)
I have this method in my GraphicDevice class.

void GraphicDevice::enableVertexAttribs(GLuint numVertexAttrib)
{
    const GLuint currNumAttrib(state_.activeVertexesAttribs_);
    if (currNumAttrib > numVertexAttrib)
    {
        for (GLuint i = numVertexAttrib; i < currNumAttrib; ++i)
        {
            glDisableVertexAttribArray(i);
        }
    } else if (currNumAttrib < numVertexAttrib)
    {
        for (GLuint i = 0; i < numVertexAttrib; ++i)
        {
            glEnableVertexAttribArray(i);
        }
    }
    state_.activeVertexesAttribs_ = numVertexAttrib;
}

The class save the current state of openGl and try to minimize the number of gl call.
When used with vertexArrayObject the state became a mess. It’s like vertexArrayObject changes the state of the openGl

In my code i’m doing:

glBindVertexArray(vao1)
...
enableVertexAttribs(3)
...
glBindVertexArray(0)
 
 
glBindVertexArray(vao2)
...
enableVertexAttribs(1); // this one will only disable vertexAttrib 2 and 1 because the class thinks that vertexAttrib 0 is already enabled
...
glBindVertexArray(0)

the geometry that I draw with vao2 is invisible and when I capture the the frame with a debuger (nVidia nSight) it say the all attribute are disabled cause the empty vao2 binding.
Seems that vao also change the current bound buffers.
It’s the correct behaviour?

I’m using nVidia driver 326.19