Can anyone explain blending to me better than the OpenGl Programming Guide can. I know to make something transparent, you use
But I don't understand why that works and I don't understand what all the other Macros do here are all of them
GL_ZERO source or destination (0, 0, 0, 0)
GL_ONE source or destination (1, 1, 1, 1)
GL_DST_COLOR source (Rd, Gd, Bd, Ad)
GL_SRC_COLOR destination (Rs, Gs, Bs, As)
GL_ONE_MINUS_DST_COLOR source (1, 1, 1, 1)-(Rd, Gd, Bd, Ad)
GL_ONE_MINUS_SRC_COLOR destination (1, 1, 1, 1)-(Rs, Gs, Bs, As)
GL_SRC_ALPHA source or destination (As, As, As, As)
GL_ONE_MINUS_SRC_ALPHA source or destination (1, 1, 1, 1)-(As, As, As, As)
GL_DST_ALPHA source or destination (Ad, Ad, Ad, Ad)
GL_ONE_MINUS_DST_ALPHA source or destination (1, 1, 1, 1)-(Ad, Ad, Ad, Ad)
GL_SRC_ALPHA_SATURATE source (f, f, f, 1); f=min(As, 1-Ad)
You're specifying how you want everything to be blended.
glBlendFunc(source factor, destination factor)
The source color will be whatever you last specified with glColor, or the current texture that you're working with. The destination is what is already sitting in memory in the color buffer. So glBlendFunc will take the factors of those two to figure out what new color should be there
final color = source factor * source color + destination factor * destination color
Looking back at the line you wrote, glBlendFunc is telling OpenGL to scale your source by the alpha channel you specified. The destination will be scaled by one minus the alpha channel of the source.
So if the source had an alpha of 1.0, which would be full alpha, the source would be scaled by 1 and the destination would be scaled by 0, making the source color completely overide the destination. If the alpha were 0.5, the source colors would be halved, and the destination would be scaled by 1 - 0.5, which comes out to half as well, giving you a 50/50 blend.
The other macros will cause different calculations to be made. but they will all follow the basic formula I have above. I hope that clears things up.
Thank you. I have posted in on more than 3 forums and you are the only one to respond. I understand now and greatly appreciate it.
you may find this link of use,
this link of use
There was a discussion about blending and the formulas for several types on the GD board about 2 weeks ago.