PDA

View Full Version : Multi-textures and vertex arrays



gstrickler
06-13-2006, 10:02 AM
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 ); // vertexMy 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.

Jackis
06-13-2006, 10:17 AM
Hi!

There is no glMultiTexCoordPointer() or something like this.

So, your way is the only right way to enable multi-texturing. Firstly, glClientActiveTextureARB() tells which unit to use, then, glEnableClientState() and glTexCoordPointer() do what you want. Disabling is right also!

Dark Photon
06-14-2006, 06:40 AM
Jackis:
There is no glMultiTexCoordPointer() or something like this.

So, your way is the only right way to enable multi-texturing. Firstly, glClientActiveTextureARB() tells which unit to use, then, glEnableClientState() and glTexCoordPointer() do what you want. Disabling is right also! Alternatively, use:

glEnableVertexAttribArray(,ARB}
glVertexAttribPointer{,ARB,NV}

gstrickler
06-14-2006, 07:01 AM
thanks for the responses. That's just what I needed.