Right now I use display lists, and want to transition to vertex arrays and VBOs. But I have a question about how to use vertex arrays for multi-texturing. (I don’t have any code problems yet, but need some help getting started. Thus the pseudo code that follows.)
I do the following to send vertex data (I’m using shaders to combine the textures and do surface bump mapping)
// for each vertex…
glNormal3f( nx, ny, nz ); // normal vector
glTexCoord2f( u,v ); // base texture coordinates
glMultiTexCoord2f( decal_unit, du, dv ); // decal texture coordinates
glMultiTexCoord3f( tan_unit, tx, ty, tz ); // tanget texture coordinates
glVertex3f( vx, vy, vz ); // vertex
My question is… is there a vertex array equivalent to glMultiTexCoord, or should I setup the arrays like this…
// setup vertex array…
EnableClientState ( NORMAL_ARRAY );
NormalPointer( float, 0, pNormal );
ClientActiveTexture( BaseTextureUnit ); // << is this the right way to
EnableClientState ( TEXTURE_COORD_ARRAY); // << setup multi-texture units
TexCoordPointer ( 2, float, pBaseTex ); // << using vertex arrays ?????
ClientActiveTexture( DecalTextureUnit ); // <<
EnableClientState ( TEXTURE_COORD_ARRAY); // <<
TexCoordPointer ( 2, float, pDecalTex); // <<
ClientActiveTexture( TangentTextureUnit ); // <<
EnableClientState ( TEXTURE_COORD_ARRAY); // <<
TexCoordPointer ( 3, float, pTangents); // <<
EnableClientState ( VERTEX_ARRAY );
VertexPointer( 3, float, 0, pVertex );
EnableClientState ( INDEX_ARRAY );
IndexPointer( int, 0, pIndex );
// draw the arrays…
DrawArrays( mode, 0, count );
// clean up…
DisableClientState ( INDEX_ARRAY );
DisableClientState ( NORMAL_ARRAY);
DisableClientState ( VERTEX_ARRAY);
ClientActiveTexture( BaseTextureUnit ); // << disable each texture unit
DisableClientState( TEXTURE_COORD_ARRAY); // << this way ?????
ClientActiveTexture( DecalTextureUnit );
DisableClientState( TEXTURE_COORD_ARRAY);
ClientActiveTexture( TangentTextureUnit );
DisableClientState( TEXTURE_COORD_ARRAY);
Thanks in advance for help. Just need to get my head around how to approach this.