Texture mapping messes with colors

Started by
2 comments, last by silverphyre673 18 years, 11 months ago
Hey. I'm trying to do some simple texture mapping (which I've done before). I can get the texture mapping to work, say, making a cube spin in the program with a texture on each face. However, if I load textures into the program, it messes with all the other colors. What it seems to be doing is coloring everything according to the colors in the texture. Its very odd. Just as a test, I took the source from NeHe's lesson #6, and tried drawing a white line right after drawing the cube, by adding this code:

glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_LINES);
    glVertex3f(-2.0f, -3.0f, -1.0f);
    glVertex3f(2.0f, 1.0f, 1.0f);
glEnd();


The line ended up being drawn correctly, but it is dark blue instead of white! To test and see what the problem was, I started commenting things out. Commenting out the cube drawing procedure in DrawGLScene() didn't affect the line's color, but when I also commented out the call to LoadGLTextures(), the function that NeHe uses to load a bitmap texture, the line was drawn white. Any thoughts on why this happens? Thanks. [EDIT] maybe this should be moved to the NeHe forum? I don't know.
my siteGenius is 1% inspiration and 99% perspiration
Advertisement
you need to disable texturing to stop that from happening, a glDisable(GL_TEXTURE2D); will do it
Hmm try adding glDisable(GL_TEXTURE_2D) before you render the line and glEnable(GL_TEXTURE_2D) after you finished rendering the line

[EDIT] posted to late [headshake]
thanks! That was quite annoying. I knew it must have something to do with having the texture mapped onto my polys. You guys rule.
my siteGenius is 1% inspiration and 99% perspiration

This topic is closed to new replies.

Advertisement