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.
Vertex Arrays with Multitexture
Started by Obunako, Aug 11 2003 07:22 PM
1 reply to this topic
#1
Posted 11 August 2003 - 07:22 PM
#2
Posted 03 December 2008 - 02:09 AM
You've probably figured this out, but for future reference you just need to make the "EnableClientState" call *after* activating the appropriate client texture unit, like so:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,...); /* position */
glClientActiveTextureARB (GL_TEXTURE1_ARB);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(4,GL_FLOAT,...); /* texcoord1 */
glClientActiveTextureARB (GL_TEXTURE0_ARB);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3,GL_FLOAT,...); /* texcoord0 */
The trouble here is that glEnableClientState applies to the *current* texture unit, like most of the texture state, so you've got to turn it on for *each* unit. The same thing works for vertex arrays as well as vertex buffer objects.
Be sure to glActiveTextureARB and glEnable(GL_TEXTURE_2D) for each unit before rendering too!
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,...); /* position */
glClientActiveTextureARB (GL_TEXTURE1_ARB);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(4,GL_FLOAT,...); /* texcoord1 */
glClientActiveTextureARB (GL_TEXTURE0_ARB);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3,GL_FLOAT,...); /* texcoord0 */
The trouble here is that glEnableClientState applies to the *current* texture unit, like most of the texture state, so you've got to turn it on for *each* unit. The same thing works for vertex arrays as well as vertex buffer objects.
Be sure to glActiveTextureARB and glEnable(GL_TEXTURE_2D) for each unit before rendering too!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











