weird colors ?
When I load a image using the :
glTexImage2D() function my colors fuc* up...
So that the color 255,255,255 aint white anymore but some kind of light blue/green color.
When i remove the call to glTexImage2D() i get normal colors again.
Anyone got any ideas ?
OpenGL is a state machine. When you enable texturing it remains enabled until you disable it. When you specify a texture coordinate it applies to all subsequent vertices until you change it. So:
is actually equivalent to:
So your coloured quad is actually textured with a single texel from your texture.
The solution, as stated by Trienco above, is to disable texturing for any objects you don''t want textured.
glEnable(GL_TEXTURE_2D);// try to draw textured quadglColor3f(1, 1, 1);glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(1, 0); glVertex2f(1, 0); glTexCoord2f(1, 1); glVertex2f(1, 1); glTexCoord2f(0, 1); glVertex2f(0, 1);glEnd();// try to draw coloured quadglColor3f(1, 0, 0);glBegin(GL_QUADS); glVertex2f(2, 0); glVertex2f(3, 0); glVertex2f(3, 1); glVertex2f(2, 1);glEnd();
is actually equivalent to:
glEnable(GL_TEXTURE_2D);// try to draw textured quadglColor3f(1, 1, 1);glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(1, 0); glVertex2f(1, 0); glTexCoord2f(1, 1); glVertex2f(1, 1); glTexCoord2f(0, 1); glVertex2f(0, 1);glEnd();// try to draw coloured quadglEnable(GL_TEXTURE_2D); // texturing still enabledglColor3f(1, 0, 0);glBegin(GL_QUADS); glTexCoord2f(0, 1); // last texture coord repeated glVertex2f(2, 0); glTexCoord2f(0, 1); // last texture coord repeated glVertex2f(3, 0); glTexCoord2f(0, 1); // last texture coord repeated glVertex2f(3, 1); glTexCoord2f(0, 1); // last texture coord repeated glVertex2f(2, 1);glEnd();
So your coloured quad is actually textured with a single texel from your texture.
The solution, as stated by Trienco above, is to disable texturing for any objects you don''t want textured.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement