PDA

View Full Version : blend constant color



speedy gonzalez
11-10-2004, 12:28 PM
Hello, I have an image with only one channel in it: the alpha.

Now I want to blend a constant color (say yellow) with the current frame buffer image using my image as the alpha factor.

So I would like to do a call to glDrawPixels(GL_ALPHA) using my alpha image with a blend function set up to do something like:

new_color = constant_color*alpha + dest*(1-alpha)

I looked at the blend colour extension but I dont think I can use it to do the equation above
(I dont want src*constant_color...).

Really what I want is a way to have glDrawPixels to convert my alpha to (RedConstant, GreenConstant, BlueConstant,alpha) instead of (0,0,0,alpha) it's doing now with the GL_ALPHA argument.

Any other way to do this ?

The only way I found to resolve my problem is to use the pixel transfer functions (scale=0, bias=my constant) but that turns out to be super slow on my card (software implemented when scale!=1).

MikeC
11-10-2004, 12:48 PM
Any particular reason why you can't call glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and draw a yellow rectangle textured with your image?

speedy gonzalez
11-11-2004, 04:57 AM
Yes that should work.

Except that I have to do this at every frame (the alpha changes at every frame) and I wanted to stay away from glTexSubImage2D as this one is currently very slow on a Nvidia FX3400.

I was really hoping we could set the constant RGB color used by glDrawPixels when we pass GL_ALPHA....

The_Nerd
11-11-2004, 09:47 AM
I could be wrong, but I think glDrawPixels is slower the glTexSubimage