how to make a RGBA image fade away?

Member
Posts: 321
Joined: 2004.10
Post: #1
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.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
glColor works with textures.
Quote this message in a reply
Member
Posts: 157
Joined: 2002.12
Post: #3
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.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
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)
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #5
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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
It depends what you have set for TexEnv... MODULATE means "multiply". Read the man pages.
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #7
I read the man pages; it's the understanding that eludes me Smile
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #8
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Fade Particle to black bonanza 8 5,117 Apr 3, 2008 05:24 AM
Last Post: bonanza
  Problems trying to fade in windowed mode Wowbagger 4 3,560 Aug 13, 2007 12:11 PM
Last Post: Wowbagger