Depth buffering & transparency plz. help!

I got a 32bpp texture wih an alpha channel, and a few holes in it.
Is there a way to write to the depth buffer only the texels with alpha!=0 ?

but:
[ul][li]Dont want to disable depth writing.[/li]Sorting wont do because i want polygons to intersect.[/ul]

I think it might be possible, cause trees made of 2 intersecting masked textures are quite common.

I’d apreciate any help

glAlphaFun( GL_GREATER, 0 );
glEnable( GL_ALPHA_TEST );

The alpha test is done before writing/comparing to the color/depth/stencil buffers, so it will treat texture pixels that do not pass the alpha test as non existing. This can actually speed up rendering too, if you are fill rate limited, since alpha testing is so early in the pipeline (before framebuffer access).

Thanx a lot Marcus,

but i cant get the glAlphaFunc to work

more details here:
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/011801.html