multitexturing

Hi, I have a problem with this code below: I’d like to use multitexturing and when I inserted the code to do this, my entire scene takes colors of texture (eg appear more brown) or the light seems fall down; Multitexturing seems works…but I have this change of ‘color’ Why this? Is my code right? Thanks

 
void initGL() 
  glGenTextures(1, &tex);
  glGenTextures(1, &lastTex);
  glBindTexture(GL_TEXTURE_2D, lastTex );	
  gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tt.width(),  
     tt.height(), GL_RGBA, GL_UNSIGNED_BYTE, tt. 
     bits() );			
  glBindTexture(GL_TEXTURE_2D, tex);		
  gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tx.width(), 
     tx.height(), GL_RGBA, GL_UNSIGNED_BYTE, tx.
     bits() );							
 
void drawGL() 
  glActiveTextureARB(GL_TEXTURE0_ARB);	
  glBindTexture(GL_TEXTURE_2D, lastTex);				
  glActiveTextureARB(GL_TEXTURE1_ARB);	
  glBindTexture(GL_TEXTURE_2D, tex);
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
  ...............

You mean you want to disable texture for the rest of the scene ? Or you don’t have proper texcoords ?

What is that code supposed to do? Can you post more code from the drawGL() function?

sorry,I’m drawing a quad; this code put texture
tex on texture lastTex; this works, but I have a change of color of all scene (eg I draw also some white lines, that they take the color of texture I loaded (eg brown);the rest of scene haven’t texture; it has only white lines and a write “hello” that change color also; (before implement multit. they were white; thanks;

void drawGL() 
 glActiveTextureARB(GL_TEXTURE0_ARB);
 glBindTexture(GL_TEXTURE_2D, lastTex);
 glActiveTextureARB(GL_TEXTURE1_ARB);
 glBindTexture(GL_TEXTURE_2D, tex);
 glBegin(GL_QUADS);
  glNormal3f(0,1,1);
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
  glVertex(V[0]);
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, .5, 0.0);
  glVertex(V[1]);
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 1.0);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, .5, .5);
  glVertex(V[2]);
  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 1.0);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, .5);
  glVertex(V[3]);
glEnd();

Mickey, the code you posted isn’t sufficient to produce textured results, unless of course there’s a glEnable(GL_TEXTURE_?) elsewhere. Supposing that there is, be sure to disable texturing afterwards, else all geometry to follow is doomed to the same textured fate.

thanks for reply; but where I must enable and where disable exactly?

Thanks

Well, reading some books or documents should really help you. Enabling/disabling should be done for each texture unit.

Originally posted by jide:
Well, reading some books or documents should really help you. Enabling/disabling should be done for each texture unit.
Yes, I red the problem; I have use enable/disable texuring; now the white light don’t take texture color but white line became gray (seems light fall down). Any hints? Thanks

hi,
I see that if I comment this code below (from my initGL), my color of white lines don’t change (and so it’s OK); was it problem lights?

GLfloat light_position[] = {0.0, 0.0, 2.0, 0.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);

What isn’t work? Thanks

what hap if u tink you light to green?

oh i hope u light did not hurt itself when it fell! :smiley:

i’m noo too but mayb i help? :slight_smile: i red redbooook and it help me much.