My HUD Changes color!!!! :(

Yes, I´m newbie
I´ve been working with NeHe´s Tutorials and mixing them with others (perhaps bad idea)

Anyway, I finaly managed to have the infamous spining cube… and textured!!!

Next step; the HUD, my fist attempt was to build a simple white rectangle, but a grey one appeared And when I press “F” (to change the texture of the cube from Nearest to Linear to MipMapping) the grey rectangle changes to a darker one

  • Nearest -> grey rectangle
  • Linear -> dark grey rectangle
  • MipMap -> dark grey rectangle

Here´s some code:
glGenTextures(3,&texture[0]);
// Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Create Linear Filtered Texture
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, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,TextureImage[0]->sizeX,TextureImage[0]->sizeY,GL_RGB,GL_UNSIGNED_BYTE, TextureImage[0]->data);

//That is part of the code that creates the
// textures

int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,z);
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.0f);
glBindTexture(GL_TEXTURE_2D, texture[filter]);
//When you press F “filter” cycles trough
//[0,1,2] ;the textures from above

glBegin(GL_QUADS);

//The six faces of the cube with normals
//and texture coordinates
glEnd();
//*********
//** HUD **
//*********
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
gluOrtho2D (0, 10, 10,0 );
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glVertex2f(0.0f,0.0f);
glVertex2f(0.0f,5.0f);
glVertex2f(10.0f,5.0f);
glVertex2f(10.0f,0.0f);
glEnd();
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
return true;
}

Hope this is some stupid newbie mistake.
Thanks anyway
?

Since you said the cube was textured, I assume you enable texturing before drawing the cube, although the code doesn’t show that. But did you disable texturing before drawing the HUD? If not, the texture will be mapped to the hud aswell.

Oh, another thing I noticed is your inefficient use of three identical textures. Just upload the texture once and change the filtering mode, not texture ID, when the user press the keys to change filtering. Since you’re going to use a mipmapped filter at some point, keep the mipmap version of the texture.

Thx Bob!!!

As I said it was a stupid newbie problem
Anyway, I´ll be bothering you guys here prety soon.

BTW I had to enable texture at the begining of DrawGlScene (to draw the cube, duh!) and then disable it before drawing the hud…
That way it works

But is there a problem with performance? I mean, in most cases (with no hud) the texture is enabled in the InitGl function.

Again thanks…
?
P.D.: I just followed the NeHe´s tutorial, so he´s guilty for the “ineficient” use of textures