• Advertisement
Sign in to follow this  

dynamically coloring a texture

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

I am drawing textured quads on the screen. Right now, the texture is black and white, and I was wondering if there was a way to replace white portion of the texture with a glColor()? I am trying to use this in combination with a particle generator to get lots of same-shaped but different colored particles. I would prefer to use a quad as opposed to making the desired shape out of vertex geometry. Maybe there is another common way to achieve this effect? Thanks

Share this post


Link to post
Share on other sites
Advertisement
set the texture env tp eg GL_MODULATE
and use glColor..(..) and draw the quad

Share this post


Link to post
Share on other sites
If I understand you correctly, this should be as simple as using glColor() and making sure that your texture environment is set to modulate (GL_MODULATE), which will combine the texture's colors with the computed colors. This is usually done to allow lighting to work with textured geometry, but also takes care of your "problem."

To do this, use a call to glTexEnv, such as this (taken from here):
glTexEnv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

Note that this is the default, so it should work without this line, unless you've specified it to be GL_DECAL somewhere. If you're in doubt, throw the call in, it can't hurt anything too badly, just remember to set it back if you don't want it later in your rendering.

If that's not what you're after, I'll need you to be a little more clear about what still isn't going as you'd like it to.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement