Jump to content
  • Advertisement
Sign in to follow this  
Anon Mike

Dynamic alpha for images

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

Two questions... First, I have an RGBA image. Is there a way to draw the image while applying a global alpha to the whole thing without manually adjusting the image data? The global alpha would be in addition to whatever alpha the individual pixels have. The effect I want is a "fade to background" similiar to how many mmp's let you adjust the transpancy of their UI on the fly. I've found several things about fading to a color but that's not what I want. Secondly, I have a different image that consists only of alpha. Is there a way to draw this image while applying a global color to it? I tried calling glColor before drawing the alpha-image but the color wasn't picked up. The application for this is my font engine which outputs just the alpha channel of anti-aliased text. They're basically the same question to my mind. Some sort of glRasterColor api would solve both neatly but alas...

Share this post


Link to post
Share on other sites
Advertisement
Using glColor and a GL_MODULATE texture environment should be all you need for both questions.

If your fonts are bitmap fonts make sure that you set the color before the raster position.

Share this post


Link to post
Share on other sites
Does that mean I have to use a texture instead of just calling glDrawPixels?

Is there a good explanation of glTexEnv someplace? My reference (OpenGL Programming guide) isn't very understandable IMHO.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anon Mike
Does that mean I have to use a texture instead of just calling glDrawPixels?

Is there a good explanation of glTexEnv someplace? My reference (OpenGL Programming guide) isn't very understandable IMHO.


Ah sorry, I thought you meant with textures. I'm not really sure how you would do it with glDrawPixels, I haven't really looked into it too much.

Honestly, there's not much of a point in using glDrawPixels as opposed to a textured quad. Texturing is must faster, you can do some pretty nifty things with textures, and if you need to change the texture data at all you can just keep a copy of it in memory and upload it when it changes, instead of sending the data every frame with glDrawPixels.

The GL Spec has very detailed info about texture environments.
And here's the GL_ARB_texture_env_combine extension spec, it's pretty much all in the 2.0 gl spec though, so it's not that much more useful.

Good luck! [smile]

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!