PDA

View Full Version : There can be only one



the_sausager
04-11-2001, 07:45 PM
Hey all,
i was wondering if there is a blend function that would eliminate a certian color within a function. Is that at all possible with opengl? thanks for you help

the_sausager

Sheepie
04-11-2001, 09:23 PM
You didn't say if you wanted to have the source color masked or the destination color masked, or both so I will tell you this much-

You can perform blending ops with a Source multiplier as the Destinations color, or vice-versa. I suppose if you made your source a Red material for example, you could use it as a Destination multiplier and that would remove the Green/Blue components from your destination. Something along these lines-

glEnable(GL_BLEND)
glBlendFunc(GL_ZERO,GL_SRC_COLOR)
*** Draw object ***

This would filter the Destination(what is already drawn) by the Source(Object drawn) by the Color of the source.

You can also use-
glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR)

This would have the inverse effect. Where Red is fully bright it would be removed.

If you are looking to simply filter the colors being drawn, you may wish to use-

void glColorMask(
GLboolean red,
GLboolean green,
GLboolean blue,
GLboolean alpha
);

This will enable you to filter certain colors from being written to the color buffer, but be aware, this causes a big performance hit. http://www.opengl.org/discussion_boards/ubb/smile.gif