Sign in to follow this  

Multitexturing shows only one texture

This topic is 4305 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 just trying to get a good idea of idea of how multitexturing works but I cannot get my test program to show more then one texture at a time. Can some one give me a hand? Here is a snip of my code. Thanks for your help!
   glClearColor (0.0, 0.0, 0.0, 0.0);
   glShadeModel(GL_FLAT);
   glEnable(GL_DEPTH_TEST);

   makeCheckImages();

   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   glGenTextures(2, texName); 
   
   /***** texName[0] is a black and white checherboard ******/
   glActiveTextureARB(GL_TEXTURE0_ARB);
   glBindTexture(GL_TEXTURE_2D, texName[0]); 
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, 
                checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); 
   glEnable(GL_TEXTURE_2D);
                
   /***** texName[1] is a red and black checker board ******/
   glActiveTextureARB(GL_TEXTURE1_ARB);
   glBindTexture(GL_TEXTURE_2D, texName[1]);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, 
                checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, otherImage); 
   glEnable(GL_TEXTURE_2D);
}

void display(void)
{     
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glActiveTextureARB(GL_TEXTURE0_ARB);
   glBindTexture(GL_TEXTURE_2D, texName[0]); 
   glBegin(GL_QUADS); 
   glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
   glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
	glVertex3f(-2.0, -2.0, 0.0);
	
   glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 8.0, 0.0);
   glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0);
	glVertex3f(-2.0, 2.0, 0.0);
	
   glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 8.0, 8.0);
   glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0);
	 glVertex3f(2.0, 2.0, 0.0);
	 
   glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 8.0);
   glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 1.0);
	glVertex3f(2.0, -2.0, 0.0);
   glEnd(); 

   glutSwapBuffers();//swap our double buffer
}

Share this post


Link to post
Share on other sites
How do you want bind the second texture if you don`t active GL_TEXTURE1_ARB?
I don`t see in your display function:
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, texName[1]);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks for your help. I commented out the decal line at worked right away.

Share this post


Link to post
Share on other sites

This topic is 4305 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