Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CoMaNdore

weird colors ?

This topic is 5327 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
Advertisement
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:

glEnable(GL_TEXTURE_2D);
// try to draw textured quad

glColor3f(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 quad

glColor3f(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 quad

glColor3f(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 quad

glEnable(GL_TEXTURE_2D); // texturing still enabled

glColor3f(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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!