PDA

View Full Version : OpenGL specific Blending Functions



WILL
12-11-2006, 01:35 PM
I know that this may be obvious to most already using OpenGL, but I'm still fairly new to it so that said...

How do I ADD, SUB and MUL a texture to the screen? A simple alpha isn't really what I'm going for as I'm trying to create an explosive effect that will brighten the colors as they are combined on the screen.

I'm almost sure it's the glBlendFunc(); function... but what are the settings I want?

WILL
12-11-2006, 02:39 PM
Ouch... :P figured it out on my own. :roll:

You'll want to set...

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

...then adjust it using...

glColor4f(1, 1, 1, me);


Honestly though, coming from a genrally 2D background, some of the definitions are somewhat unfamiliar to me. It would be handy to have a small guide for converting my existing 2D knowlage to the OpenGL state settings. :scratch:

JSoftware
12-11-2006, 02:42 PM
Additive: glBlendFunc(GL_ONE, GL_ONE);
Subtractive: glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR);
Multiplicative: glBlendFunc(GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR);

I might be wrong on the last one though as I haven't used blending for a long time

grudzio
12-11-2006, 09:28 PM
On www.delphi3D.net there is an application which shows all OpenGL blend modes in action. Look for blender.zip in downloads -> libraries & tools section.