Drawing color and textures

Started by
4 comments, last by Johnn 19 years, 10 months ago
Im doing a simple spinning textured cube based on the tutorial at nehe. When I load the texture, which is bluish, everything else I draw on screen seems to get affected by the texture color. For instance, I draw a white quad "ground" below the cube. If I comment out the texture loading, its white like it should. But if I put texturing on, the quad appears blue! And if I use black as a drawing color for the quad ground, everything disapears, even the textured cube (the clear color being black too). If I use red, I only see a bit of red on the cube, etc. Now, im wondering is it normal that the texture has an effect on the color of everything thats being drawn? Because thats not too practical... Thanks for the help!
Advertisement
add glColor3f(1.0f, 1.0f, 1.0f); right before you draw the white cube.


Sharp Basic - Coming summer 2004!
Sign Up For Sharp Basic Beta Testing!!!
Hmm.. thats what I have.
Just try it out for yourself. Download the nehe source of the textured cube and try to draw a quad of any color anywhere on the screen.


http://nehe.gamedev.net/data/lessons/vc/lesson06.zip
for instance, try to add this in the render() function:

glColor3f(1.0, 0.0, 0.0);

the cube will be looking totally different...

[edited by - johnn on June 2, 2004 2:21:12 PM]

[edited by - johnn on June 2, 2004 2:24:26 PM]
If you''re drawing a cube of specified color(s), then you need to disable texturing via glDisable (GL_TEXTURE_2D) (for 2D texturing, which I''m assuming is what you''re using). OpenGL needs to know whether you want texturing or not. If you have it enabled and you are trying to draw a colored quad, the color is going to have an effect on the texture, not the texture have an effect on the color - at least, that''s how I think of it. Also, as DerAnged said, be sure to set the color to white before drawing textured objects.

~Urayami
~Urayami
Thats better now

Thanks for the help!
be sure to have texturing disabled before drawing the rest of the scene if you are not using textures.

As urayami said, if you enabled GL_COLOR_MATERIAL, you will be able to give a taint of a specific color to your textures faces. (like multiplying the value of each pixel by the given color value. If you used photoshop and filled an area using the multiply option, that''s exactly it)
If you multiply with black ( 0.0, 0.0, 0.0), all you pixels will be black)
(that''s the use of glColor3f(1.0,1.0,1.0) Deranged mentionned. If you multiply the values of the pixels of the texture by 1.0 it will not change the texture)

Remember that you are in a loop: if you set a color after drawing the cube to draw the quad, and you don''t specify another color before drawing the cube on the next pass, the color you used on the quad will affect the cube.

This topic is closed to new replies.

Advertisement