how to make a RGBA image fade away?
I should probably know this, but i've got an RGBA image of 128x128 texels
and I just want the entire thing to fade away slowly until it is invisible?
glColor4x( r, g , b, alpha); is only for geometrical drawings and not for textures? right?
Sorry if this is a stupid question.
and I just want the entire thing to fade away slowly until it is invisible?
glColor4x( r, g , b, alpha); is only for geometrical drawings and not for textures? right?
Sorry if this is a stupid question.
glColor works with textures.
Code:
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, texid);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f(r, g, b, a);
if(a<1.0) a+=0.05;
Draw();or something like that.
Note that the calls to glEnable, glBlendFunc, and glTexEnvi only need to be called once. (just make sure the texture is bound when you call glTexEnvi, though)
Thanks.
Oops, I had commented out my glTexEnv(..) command. However, with that said,
how does the alpha of the glColor() command interact with the alpha bytes in the
RGBA texture? Does the glColor() override everything in the texture?
Oops, I had commented out my glTexEnv(..) command. However, with that said,
how does the alpha of the glColor() command interact with the alpha bytes in the
RGBA texture? Does the glColor() override everything in the texture?
It depends what you have set for TexEnv... MODULATE means "multiply". Read the man pages.
I read the man pages; it's the understanding that eludes me
With GL_MODULATE, it multiplies the color values of the texture with the color values of the fragment. So if the color is {1, 1, 1, 1}, then it will be the exact same color as the texture. If you adjust the value of the alpha, then it will multiply the alpha of the image. Once it reaches 0, the image will be transparent.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Fade Particle to black | bonanza | 8 | 4,665 |
Apr 3, 2008 05:24 AM Last Post: bonanza |
|
| Problems trying to fade in windowed mode | Wowbagger | 4 | 3,260 |
Aug 13, 2007 12:11 PM Last Post: Wowbagger |
|

