Vertex Arrays with Multitexture, some help

Hello, i try to use Vertex Arrays With Multitexture extension, but don’t work it.

my source code…

Start up function ( Only once, at the begin of my app )

//Load TextureFile1 ( some code )

glGenTextures(1,&ntexture[0]);
glActiveTextureARB (GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, ntexture[0]);
glEnable (GL_TEXTURE_2D);
glTexImage2D(GL_TEXTURE_2D, 0,3, 256, 256, 0,GL_BGR_EXT, GL_UNSIGNED_BYTE,sprite);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP);

I repeat this code for texturefile2 changing …TEXTURE0… by …TEXTURE1… and ntexture[0] by ntexture[1].

( this parts seems ok, because in non multitexture mode, no problems produce )

glEnable (GL_TEXTURE_2D);
glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);

RenderFunction

glActiveTextureARB (GL_TEXTURE0_ARB);
glClientActiveTextureARB (GL_TEXTURE0_ARB);
glTexCoordPointer (2,GL_FLOAT,0,na);
glVertexPointer (3,GL_FLOAT,0,va);

glActiveTextureARB (GL_TEXTURE1_ARB);
glClientActiveTextureARB (GL_TEXTURE1_ARB);
glTexCoordPointer (2,GL_FLOAT,0,na);

glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices );

glActiveTextureARB (GL_TEXTURE0_ARB);
glClientActiveTextureARB (GL_TEXTURE0_ARB);
glTexCoordPointer (2,GL_FLOAT,0,na);
glVertexPointer (3,GL_FLOAT,0,va);

glActiveTextureARB (GL_TEXTURE1_ARB);
glClientActiveTextureARB (GL_TEXTURE1_ARB);
glTexCoordPointer (2,GL_FLOAT,0,na);

glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices );

… ;-( ;-( i render all balck ;-( ;-(

I don’t understand the diferences between alActive… and glClientActive… functions. May be this is the problem of my render function.

Thanks All.

Do it like this:

glVertexPointer(...);
glEnableClientState(GL_VERTEX_ARRAY);

glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(...);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(...);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glDrawElements(...);

[This message has been edited by jra101 (edited 08-15-2003).]

I don’t understand the diferences between alActive… and glClientActive… functions. May be this is the problem of my render function.

Just remember that if you are using vertex arrays, then use the Client functions, ie. glClientActiveTexture. Otherwise if you are say using immediate mode (glVertex3f and family) then use the non client functions, ie. glActiveTextureARB.

-SirKnight

Ok you probably want to know why. Well I’ll tell you. One reason why you use the Client functions for vertex arrays is, for example, the functions glEnable and glDisable, or the ActiveTextureARB func, can be stored into a display list, but the specification of vertex arrays can’t because the data you are using is stored on the client side. That’s why the word Client is in those functions, and like I said before, when using vertex arrays, use the Client functions.

-SirKnight

Me too
ClientActiveTexture basically specifies to which texture unit the next TexPointer call will be applied. Vertex array pointers are client state

(non-Client) ActiveTexture routes glEnable(GL_TEXTURE_*), TexEnv and TexParameter calls. These are server state