Hi
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));
glClientActiveTexture(GL_TEXTURE1);
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:
glBindVertexArray(…)
glBindBuffer(GL_ARRAY_BUFFER, …)
glDrawRangeElements(…);
–> Now i got nice crash in glDrawRangeElements (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 ?
If i do something like this:
glGenVertexArrays(1, &SomeID);
glBindVertexArray(SomeID)
glBindBuffer(GL_ARRAY_BUFFER, SomeID_VB)
glVertexPointer and others now
then when comes to rendering:
glBindVertexArray(SomeID)
glBindBuffer(GL_ARRAY_BUFFER, SomeID_VB)
glDrawRangeElements(…)
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 ? :>