Dynamic alpha for images

Started by
2 comments, last by Kalidor 19 years ago
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...
-Mike
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.
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.
-Mike
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]

This topic is closed to new replies.

Advertisement