Skip to main content
gamedev.net
🔒 Locked

dynamically coloring a texture

Started by Maverick_24 Apr 21, 2009 at 11:37 AM 1 replies 800+ views
Original Post
Maverick_24
Maverick_24
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
zedz
zedz
set the texture env tp eg GL_MODULATE
and use glColor..(..) and draw the quad
jouley
jouley
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.