Jump to content
  • Advertisement
Sign in to follow this  
zorger

Multitexturing shows only one texture

This topic is 4525 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
Advertisement
Are you sure GL_DECAL is what you want for the second texture unit? (It may be, but it's not clear from what you posted.)

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!