glColor4f and glBlendFunc for fading to white?

Post: #1
hey everyone, potentially dumb question alert...

i know how to use glColor4f to get a texture to fade to black, or fade to pretty much any color, except white... my images are not greyscale, they have their own color information..

so let's say I want an enemy to flash white when it gets damaged or something. clearly color4f (1,1,1,1) just gives the texture all its proper colors... i think there may be something i can tweak with glBlendFunc to get the effect i want, but...

I'm sure this has a relatively easy solution..
Quote this message in a reply
Posts: 529
Joined: 2003.03
Post: #2
Disable GL TEXTURE 2D and just draw it white?

"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Quote this message in a reply
Posts: 834
Joined: 2002.09
Post: #3
Lurie's solution works if you're doing 3d models - but if you're doing billboarded sprites, it won't. In that case, your only solution (that I know of) is to have the sprites duplicated with only the alpha information filled out, all the color channels white. Perhaps you could find a way with glBlendFunc?
Quote this message in a reply
Posts: 1,482
Joined: 2002.09
Post: #4
I can think of two sort-of good solutions.
1) Use the additive texture environment function instead of modulate.
2) Do some finagling so that your sprite's alpha mask is drawn into the framebuffer and then blend a colored quad over the top of that using the framebuffer alpha as the mask.

I might fiddle around with this tonight.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Using blending for a text fading effect. cjcaufield 2 4,326 Jun 30, 2010 08:21 PM
Last Post: cjcaufield
  glColor4f not working after glDrawArrays Technoman 2 6,336 Aug 15, 2009 08:09 AM
Last Post: Technoman
  glBlendFunc leRiCl 3 4,015 Jul 10, 2008 06:49 AM
Last Post: aarku
  Cocoa loaded textures have white edges Jake 6 4,150 May 6, 2005 09:17 AM
Last Post: Jake
  White screen problem Iceman 7 4,033 Mar 31, 2005 10:41 PM
Last Post: OneSadCookie