   Texturing 2 different items with 2 different textures
  I am pulling my hair out trying to figure out why I can't draw two different quads with two different textures.  Instead, what is happening is that I draw two different quads but they have the SAME texture. Help!I have cut out the important bits of code.  I have successfully been able to load both textures as they are the same image with different hues.  However, I have not been able to successfully draw 2 different quads with 2 different textures.I suspect that I am missing something basic here.  Am I somehow writing the same texture to both points in the texture array?// ship textureGLuint texture[2];GLuint texture_format;void Square::show(){    glLoadIdentity();    glTranslatef(x, y, 0);   glBegin( GL_QUADS );   // ship 1 render   glBindTexture(GL_TEXTURE_2D, texture[0]);   glTexCoord2i(0, 0);  glVertex3f( 0, 0, 0 );   glTexCoord2i(1, 0);  glVertex3f( SQUARE_WIDTH, 0, 0 );   glTexCoord2i(1, 1);  glVertex3f( SQUARE_WIDTH, SQUARE_HEIGHT, 0 ); glTexCoord2i(0, 1);  glVertex3f( 0, SQUARE_HEIGHT, 0 );// ship 2 render   glBindTexture(GL_TEXTURE_2D, texture[1]);   glTexCoord2i(0, 0);  glVertex3f( 300, 0, 0 );    glTexCoord2i(1, 0);  glVertex3f( 300 + SQUARE_WIDTH, 0, 0 );   glTexCoord2i(1, 1);  glVertex3f( 300 +SQUARE_WIDTH, SQUARE_HEIGHT, 0 ); glTexCoord2i(0, 1);  glVertex3f( 300, SQUARE_HEIGHT, 0 );  glEnd();}// this function should load bitmaps and convert them to texturesint LoadGLTextures(){// background loading    background = load_image("Federation Eagle Cruiser Enemy.bmp");   GLint nofcolors = background->format->BytesPerPixel;   if (nofcolors == 4)    {  if(background->format->Rmask==0x000000ff)  { bgtexture_format = GL_RGBA;  }  else  { bgtexture_format = GL_BGRA;  }    }    else if (nofcolors == 3) // no alpha channel    {  if (background->format->Rmask==0x000000ff)  {bgtexture_format = GL_RGB;  }  else  { bgtexture_format = GL_BGR;  }   }   // gonna need 2 textures here    glGenTextures(2, &texture[0]);   // texture 0 is a 2d txtureglBindTexture(GL_TEXTURE_2D, texture[0]);// the following code loads texture[0]    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexImage2D(GL_TEXTURE_2D, 0, nofcolors, background->w, background->h, 0, bgtexture_format, GL_UNSIGNED_BYTE, background->pixels);   /// ship loading    surface = load_image("Federation Eagle Cruiser.bmp");   nofcolors = surface->format->BytesPerPixel;   if (nofcolors == 4)    {  if(surface->format->Rmask==0x000000ff)  { texture_format = GL_RGBA;  }  else  { texture_format = GL_BGRA;  }    }    else if (nofcolors == 3) // no alpha channel    {  if (surface->format->Rmask==0x000000ff)  {texture_format = GL_RGB;  }  else  { texture_format = GL_BGR;  }   }  glBindTexture(GL_TEXTURE_2D, texture[1]);glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexImage2D(GL_TEXTURE_2D, 0, nofcolors, surface->w, surface->h, 0,   texture_format, GL_UNSIGNED_BYTE, surface->pixels);}
  You can't bind textures between glBegin and glEnd.   ;Quote:Original post by szecsYou can't bind textures between glBegin and glEnd.Ok.  So I just did this and still no dice:    glBegin( GL_QUADS );   // ship 1 render   glBindTexture(GL_TEXTURE_2D, texture[0]);   glTexCoord2i(0, 0);  glVertex3f( 0, 0, 0 ); // upper left   glTexCoord2i(1, 0);  glVertex3f( SQUARE_WIDTH, 0, 0 );// upper right   glTexCoord2i(1, 1);  glVertex3f( SQUARE_WIDTH, SQUARE_HEIGHT, 0 );   // bottom right   glTexCoord2i(0, 1);  glVertex3f( 0, SQUARE_HEIGHT, 0 );    // bottom left    glEnd();   glBegin( GL_QUADS );  // ship 2 render   glBindTexture(GL_TEXTURE_2D, texture[1]);   glTexCoord2i(0, 0);  glVertex3f( 300, 0, 0 ); // upper left   glTexCoord2i(1, 0);  glVertex3f( 300 + SQUARE_WIDTH, 0, 0 );// upper right   glTexCoord2i(1, 1);  glVertex3f( 300 +SQUARE_WIDTH, SQUARE_HEIGHT, 0 );   // bottom right   glTexCoord2i(0, 1);  glVertex3f( 300, SQUARE_HEIGHT, 0 );    // bottom left   glEnd();;Quote:Original post by szecsYou can't bind textures between glBegin and glEnd.;Quote:Original post by zer0sumQuote:Original post by szecsYou can't bind textures between glBegin and glEnd.Ok.  So I just did this and still no dice:    glBegin( GL_QUADS );   // ship 1 render   glBindTexture(GL_TEXTURE_2D, texture[0]);   glTexCoord2i(0, 0);  glVertex3f( 0, 0, 0 ); // upper left   glTexCoord2i(1, 0);  glVertex3f( SQUARE_WIDTH, 0, 0 );// upper right   glTexCoord2i(1, 1);  glVertex3f( SQUARE_WIDTH, SQUARE_HEIGHT, 0 );   // bottom right   glTexCoord2i(0, 1);  glVertex3f( 0, SQUARE_HEIGHT, 0 );    // bottom left    glEnd();   glBegin( GL_QUADS );  // ship 2 render   glBindTexture(GL_TEXTURE_2D, texture[1]);   glTexCoord2i(0, 0);  glVertex3f( 300, 0, 0 ); // upper left   glTexCoord2i(1, 0);  glVertex3f( 300 + SQUARE_WIDTH, 0, 0 );// upper right   glTexCoord2i(1, 1);  glVertex3f( 300 +SQUARE_WIDTH, SQUARE_HEIGHT, 0 );   // bottom right   glTexCoord2i(0, 1);  glVertex3f( 300, SQUARE_HEIGHT, 0 );    // bottom left   glEnd();Ha. Just read my own code and noticed that I still put the binding inside the begin/end.  When I took it out, it worked!  Thanks.