Jump to content
  • Advertisement
Sign in to follow this  
woodruff

OpenGL coloring textures (OpenGL)

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

Hi! I have a textured quad that I want to colorize, lets say: red. Easy task, I thought... ;) But if I use glColor4ub(255, 0, 0, 255) the "bright" colors of the texture get red but the "dark" ones stay (ie: black always stays black) I think thats because the colors get multiplied, but I don't want black to stay black I want it to turn into a darker red. How can I change this? I tried to use different glBlendFunc parameters, but that just influences how the texture is drawn on the background(-texture) One solution would be to render the same texture (changed to red in a photoshop) with 50% alpha on top of the texture, but I want to avoid that because I use various frames within the texture. Is there a elegant way of tinting the texture red? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Thanks for your reply, but thats not possible - the texture contains various colors, which should all "fade" to red... (including black)

Share this post


Link to post
Share on other sites
You'll want to look at the glTexEnv function with the GL_TEXTURE_ENV_MODE parameter (IIRC; I use shaders so I don't actually use it myself). I'm not positive if there's one that will do exactly what you want but the possible values are listed in the docs for glTexEnv.

Share this post


Link to post
Share on other sites
The easiest way to do that is to use glPixelTransfer. If you set glPixelTransferf(GL_RED_BIAS, 0.2) before creating texture, your textures' red component will be shifted by 0.2, so black pixels will became lighter.

Share this post


Link to post
Share on other sites
I tried out glPixelTransfer and glTexEnv but the results were nonsatisfying.

The only solution would be to load a the same texture again and set glPixelTransfer. So I could render the second (colored) texture above the first one and adust the "coloreness" with alpha blending...

Funny that such a simple task requires a workaround... :)

Thanks for all replys, anyway!

Share this post


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

  • 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!