blending and depth

I have a window with a bunch of flowers. The flowers are on a 24 bit .BMP which background is bright pink (RGB: 255,0,255).
I want to display some moving objects in the background while drawing the flowers in the foreground. Sometimes the objects cross the window and “crash” on the viewer.
What kind of blending function (parameters) should i use to have the bright pink pixels totally blended (transparent), but still having the depth function working?

posted by fortikur:

I want to display some moving objects in the background while drawing the flowers in the foreground. Sometimes the objects cross the window and “crash” on the viewer.

Are flowers from first sentence objects in second one?

If you want to have transparent/translucent flowers that do write to depth buffer you need alpha-blending.
Add 4th alpha component to your flowers’ image with say 1 where flower should and 0 where shouldn’t write to depth buffer - this can be done easily: 1 where color different from black, 0 otherwise.
Then use glAlphaFunc(GL_EQUAL, 1) to preserve black parts from writing to z-buffer.
If you want your flowers to be transparent too (not only translucent) - I guess you want, at least on the borders - then use some blending too. Note that in this case you have to (you should at least ) sort your flowers before sending them to OpenGL.

Hope this helps!