PDA

View Full Version : multitexturing and vertex arrays (solved)



avocados
08-01-2005, 12:13 PM
EDIT: SOLVED. Both glClientActiveTextureARB and glActiveTextureARB need to be called to set the current texture environment for the texCoord array.

I'm trying to put my heightmap in a vertex array instead of a display list but I can't get the multitexture to work. Any ideas?


glColor4f(1,1,1,1);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glVertexPointer(3,GL_SHORT,0,&mesh_s[0][0][0]);
glEnable(GL_VERTEX_ARRAY);

glActiveTextureARB(GL_TEXTURE0_ARB);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexCoordPointer(2,GL_FLOAT,0,&texcoords[0]);
glEnable(GL_TEXTURE_COORD_ARRAY);
glBindTexture(GL_TEXTURE_2D, tex2d[4]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glTexCoordPointer(2,GL_FLOAT,0,&texcoords[1]);
glEnable(GL_TEXTURE_COORD_ARRAY);
glBindTexture(GL_TEXTURE_2D, tex2d[2]);

glDrawElements(GL_TRIANGLE_STRIP, 512*2, GL_UNSIGNED_SHORT, &mesh_index[0]);

glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_VERTEX_ARRAY);

08-01-2005, 07:09 PM
Use glActiveTexture with glEnable(GL_TEXTURE_2D).

The client stuff is for, well, client stuff.

08-01-2005, 08:41 PM
Something kinda like this


glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

glClientActiveTextureARB(GL_TEXTURE0_ARB);
glTexCoordPointer(2,GL_FLOAT,0,&texcoords[0]);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTextureARB(GL_TEXTURE1_ARB);
glTexCoordPointer(2,GL_FLOAT,0,&texcoords[1]);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glEnableClientState(GL_VERTEX_ARRAY);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex2d[0]);
glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, tex2d[1]);
glEnable(GL_TEXTURE_2D);

avocados
08-01-2005, 08:50 PM
Thanks Hlz. I reordered it like that but it didn't change what's happening. Texture0 is getting the texture coordinates from the second glTexCoordPointer which is intended for texture1. Multitexturing is working now (since I removed the clienstate calls) though because texture0 is visible but tinted by what I think is a single pixel from texture1.