Sign in to follow this  

multitexturing in vertex array

This topic is 4519 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]); 

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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 ;-)

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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..)

Share this post


Link to post
Share on other sites

This topic is 4519 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this