When I bind a specific texture for drawing a quad in OpenGL, it affects all the display : if I use a red BMP file, I see all the screen like if I was wearing red glasses (same for every color : in black I see very dark, in white everything looks almost OK).
This is for texture-mapping fonts, which work well (currently I have only drawn numbers and the rest of the texture is black), but I have this weird behavior on every other surface.
No problem with other BMP files, though. It might come from this BMP file I created, but I had no problem with opening it in various image editors, and I manually check headers and data in my program which look OK.
Anybody has a clue on what could be the problem here ?
edit : this is my code to display a font :
static const GLfloat tfVertices[] = {
-.5f, -.5f, .1f,
-.5f, .5f, .1f,
.5f, -.5f, .1f,
.5f, .5f, .1f
};
GLfloat tfTextureCoords[] = {
// I compute here the coords of the desired font, that works fine.
// 4 lines of 2 float values (x, y)
};
glColor4ub(255, 255, 255, 255);
glBindTexture(GL_TEXTURE_2D, FontTextureGLnb); // when removing this (so use default texture instead of the one with fonts) I have no display bug.
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, tfVertices);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, tfTextureCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
There is no problem, that’s how OpenGL works. If you want textures, enabled them, if you don’t want textures, disable them. If you set the vertex color state to red, everything will be drawn red until you change that state.