Multiple texcoord arrays=sure, multiple color streams?

I haven’t found anything in the docs about glEnableClientState to see if the below is possible. I know there are better/other ways to do this with VBO’s, this is a question about what the spec allows.

I know it’s possible to use glTexCoordPointer() to specify multiple texture coordinates/layer like this:

        
        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, textureHandle[0]);
        glClientActiveTexture(GL_TEXTURE0);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glTexCoordPointer(2, GL_FLOAT, 0, texCoordBuffer[0]);


        glActiveTexture(GL_TEXTURE1);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, textureHandle[1]);        
        glClientActiveTexture(GL_TEXTURE1);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glTexCoordPointer(2, GL_FLOAT, 0, texCoordBuffer[1]);

        glActiveTexture(GL_TEXTURE2);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, textureHandle[2]);  
        glClientActiveTexture(GL_TEXTURE2);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);        
        glTexCoordPointer(2, GL_FLOAT, 0, texCoordBuffer[2]);    

        glDrawElements(GL_TRIANGLES,  6, GL_UNSIGNED_SHORT, indexBuffer);

This all works fine.

But can you have multiple color/normal/fog and other client state streams (glEnableClientState: GL_COLOR_ARRAY, GL_NORMAL_ARRAY, GL_SECONDARY_COLOR_ARRAY, GL_EDGE_FLAG_ARRAY, etc) as well like this:

        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, textureHandle[0]);
        glClientActiveTexture(GL_TEXTURE0);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glTexCoordPointer(2, GL_FLOAT, 0, texCoordBuffer[0]);
        glEnableClientState(GL_COLOR_ARRAY);
        glColorPointer(4, GL_FLOAT, 0, colorBuffer[0]);
        glEnableClientState(GL_NORMAL_ARRAY);
        glNormalPointer(3, GL_FLOAT, 0, normalBuffer[0]);


        glActiveTexture(GL_TEXTURE1);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, textureHandle[1]);        
        glClientActiveTexture(GL_TEXTURE1);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glTexCoordPointer(2, GL_FLOAT, 0, texCoordBuffer[1]);
        glEnableClientState(GL_COLOR_ARRAY);
        glColorPointer(4, GL_FLOAT, 0, colorBuffer[1]);
        glEnableClientState(GL_NORMAL_ARRAY);
        glNormalPointer(3, GL_FLOAT, 0, normalBuffer[1]);

        glDrawElements(GL_TRIANGLES,  6, GL_UNSIGNED_SHORT, indexBuffer);

Or does multiple arrays only work with texture coordinate layers? I’ve tried doing this with color streams, but it seems to only use the color stream set last (in the example above, it seems to always use colorBuffer[1]). l’ve never seen an example with anything other than texcoord arrays like this…

[QUOTE=mattropolis;1258066]…glEnableClientState…I know it’s possible to use glTexCoordPointer() to specify multiple texture coordinates…
But can you have multiple color/normal/fog and other client state streams (glEnableClientState: GL_COLOR_ARRAY, GL_NORMAL_ARRAY, GL_SECONDARY_COLOR_ARRAY, GL_EDGE_FLAG_ARRAY, etc) as well[/QUOTE]

You can… but not with fixed-function vertex attributes (e.g. gl{Vertex,Color,Normal,TexCoord,FogCoord,etc.}Pointer and gl{Enable,Disable}ClientState()).

The way you would do this is with generic vertex attributes (glVertexAttribPointer() and gl{Enable,Disable}VertexAttribArray) and your own custom shaders. With this approach, vertex attributes don’t have predefined semantics. They’re just generic “slots” that you can populate with whatever data you want, used however you want on the GPU.

I’m not sure exactly what you’re trying to do here, but it sounds like you’re looking for more flexibility in how different texture layers are computed and blended together. As an interim ground, you can look into whether the old ARB_texture_env_combine would give you the flexibility you want. That’s a stopgap though. The most flexible route is to just go generic vertex attributes and shaders.