Jump to content
  • Advertisement

Archived

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

Johnn

Drawing color and textures

This topic is 5223 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

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!

Share this post


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

Share this post


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

Share this post


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

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!