multitexturing in vertex array

Started by
4 comments, last by avocados 18 years, 8 months ago
I'm rendering some multitextures on objects in a display list but this mesh in the vertex array is only rendering with one texture. Does this look ok?

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

    glClientActiveTextureARB(GL_TEXTURE1_ARB);
    glEnable(GL_TEXTURE_2D); 
    glTexCoordPointer(2,GL_FLOAT,0,&texcoords[1]);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glBindTexture(GL_TEXTURE_2D, tex2d[1]); 
Advertisement
Looks good.. Have you made sure both textures were loaded correctly, and that you've set up the texture combine the way you want it?
Also, use glGetError() to see if OpenGL reports anything..
glActiveTextureARB(GL_TEXTURE0);
// setup tex 0 just like you have

glActiveTextureARB(GL_TEXTURE1);
// setup tex 1 just like you have

if you don't use the glActiveTexture it won't activate the texture units and will use unit 0 (or if you left it on some other one). You have to tell the server to activate it to. You only activated the client.

Ok well, I got a bit confuddled myself, and than I remembered glClientActiveTexture is what you use for enabling the vertex arrays. It doesn't set the actual texture unit, that is glActiveTextureARB (or just glActiveTexture).. I had used them togethor so long I forgot why I did it ;-)
"It's such a useful tool for living in the city!"
glGetError comes back with 0 after every line. The second glTexCoordPointer overwrites the first call. TEXTURE0 shows up using the texture coordinates intended for TEXTURE1 and is tinted by a single pixel from TEXTURE1. So multitexture is working but I am unable to specify texture coordinates for TEXTURE1.

    glEnable(GL_BLEND);    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);        glActiveTextureARB(GL_TEXTURE0_ARB);    glTexCoordPointer(2,GL_FLOAT,0,&texCoords[0]);    glEnable(GL_TEXTURE_COORD_ARRAY);    glEnable(GL_TEXTURE_2D);     glBindTexture(GL_TEXTURE_2D, tex2d[4]);    glActiveTextureARB(GL_TEXTURE1_ARB);    glTexCoordPointer(2,GL_FLOAT,0,&texCoords[1]);    glEnable(GL_TEXTURE_COORD_ARRAY);    glEnable(GL_TEXTURE_2D);     glBindTexture(GL_TEXTURE_2D, tex2d[2]);     glVertexPointer(3,GL_SHORT,0,&mesh_s[0][0][0]);    glEnable(GL_VERTEX_ARRAY);    glDrawElements(GL_TRIANGLE_STRIP, 512*2, GL_UNSIGNED_SHORT, &mesh_i[0]);    glDisable(GL_TEXTURE_2D);    glDisable(GL_TEXTURE_COORD_ARRAY);    glActiveTextureARB(GL_TEXTURE0_ARB);    glDisable(GL_TEXTURE_2D);    glDisable(GL_TEXTURE_COORD_ARRAY);    glDisable(GL_VERTEX_ARRAY);
Reread Name_Unknown's post ;) You need to use both glClientActiveTextureARB and glActiveTextureARB - the first for client states (enabling texture coord array and setting its pointer) and the latter for enabling texturing and binding textures.
(I totally forgot about that myself. It was a while ago I did this stuff..)
Beautifull! Thanks guys.

This topic is closed to new replies.

Advertisement