I believe the extension implicitly requires the driver to detect state changes (modelview, new Pointer calls etc) and flush it’s “compiled state” until the next draw call, so you could lock whenever you want.
However, if you look at the way Quake does it (with GLTrace), it first sets up all per-object state, then call LockArrays(), then does multiple texture state changes and DrawElements calls, then unlocks. Chances are that you’ll be compatible with most cards if you do it the same way…
So I’m going to assume:
glEnableClientState(…);
gl*Pointer(…);
glLockArraysEXT(…);
glDrawElements(…) (or glDraw);
glUnlockArraysEXT();
glDisableClientState(…);
Is that what every body is using?
Also, should I be locking and unlocking every frame, or should I lock, then run rendering until I’m thru with the Array (scene change, prog exit, etc), then unlock?
// Part of the body of the Render() method:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// == For some reason there isn’t any interleaved format with 2 texcoord, 3 vertex, 4 color, and 3 normal
// == using T2F, C4UB, V3F, N3F. I don’t honestly know why.
// glInterleavedArrays(GL_T2F_C4UB_V3F, 0, pVertexBuf);
glVertexPointer(3, GL_FLOAT, sizeof(VERTEXBUFFER), &pVertexBuf[0].Vertex);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VERTEXBUFFER), &pVertexBuf[0].ColorWithAlpha);
glNormalPointer(GL_FLOAT, sizeof(VERTEXBUFFER), &pVertexBuf[0].Normal);
glTexCoordPointer(2, GL_FLOAT, sizeof(VERTEXBUFFER), &pVertexBuf[0].TexCoord);
I believe that you can change, at a minimum, the glTexCoordPointer() (and the bound texture) while the arrays are still locked; else it wouldn’t be useful for multi-pass texturing (which it is).
I’m really just using it to accelerate the strip generation. The texture coordinates are really not even used (I’m not binding a texture - I just have it in the vertex structure format in case I decide to use it).
What I’m mostly asking is whether I’m using the locks correctly and are they in the correct place(s)?
Yes, your locks are pretty good, although you might not get much of a speed-up the way you’re using them here (especially if you were using glDrawRangeElements()).