ARB_vertex_array_object usage pattern

What is the valid usage pattern of vertex array object ?
I’m generating ID glGenVertexArrays then bind it (glBindVertexArray).
Now I’m setting some states, for example:

glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (3, GL_FLOAT, sizeof(c_OBJ_VERTEX), offsetof(c_OBJ_VERTEX, pos.x));

glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer (3, GL_FLOAT, sizeof(c_OBJ_VERTEX), offsetof(c_OBJ_VERTEX, normal.x));

now do glBindVertexArray(0);

1st question: Should I disable GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY at this point or they are disabled like befor VAO ?

Now i want to use my VAO:

glBindBuffer(GL_ARRAY_BUFFER, …)


–> Now i got nice crash in glDrawRangeElements :stuck_out_tongue: (GF 280GTX, latest nvidia drivers, vista x64 sp2)

I have lots of vertex buffers to draw (> 100) and they are in on of 4 formats,
so I want to have 4 VAOs, each of them holding state bindings to reduce number of gl* calls,
just like vertex declarations in DX.
This is the valid usage pattern ?
If Yes - where is the error ? :wink:

If i do something like this:

glGenVertexArrays(1, &SomeID);
glBindBuffer(GL_ARRAY_BUFFER, SomeID_VB)
glVertexPointer and others now

then when comes to rendering:
glBindBuffer(GL_ARRAY_BUFFER, SomeID_VB)


all is fine - but this way i need one VAO per one vertex buffer - with IMHO is not right ?

Ps. is there any WORKING example (with source code) of vertex array object ? :>

This might be helpful:

and this especially:

there are a lot of not-exact-correctly info there, but the reading worth it anyway

Once you have created the VAO bound buffers and all that and your about to render all you need to do is call glBindVertexArray and not glBindBuffer, calling glBindBuffer without glVertexPointer(or the like) confuses openGL and causes an error, the reason it works with it already bound one is because if you bind anything more than once in a row it just disregards all but the first.

you do not need to disable GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY as long as all your VAOs use the same form.
Besides, if your pondering using openGL 3.1 and glsl 1.4 you wouldn’t need glEnableClientState, glVertexPointer, glTexCoordPointer and so on.