Particles and Depth Testing

My particles are coded as such:

 
	glDisable (GL_LIGHTING);
	glEnable(GL_BLEND);
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_DST_COLOR, GL_ZERO);
	glBindTexture(GL_TEXTURE_2D, smoketexture[1]);
	particles();
	glDisable(GL_BLEND);
 

Now before that code I have code to build the rest of my scene. The problem with this code is that the particle is drawn on top of the whole scene, when I want it to be drawn infront of what is behind it, yet behind what is infront of it. But if I try to reinstate the GL_DEPTH_TEST it messes up my blending. Any ideas?

And also, how would I implement some more blending afterwards, so that the particles seem to fade accourding to my glColor4f function?

leave depth testing on
but disable depth masking glDepthMask(GL_FALSE)

easiest blend for particles is like
glBlendFunc(GL_SRC_ALPHA,GL_ONE)

which is additive blending (requires no sorting) and your alpha values influence the blend factor

other popular blend is transparency
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)

this however requires that you draw your particles in back to front order (ie furthest from camera first)

Ok, the depth mask fixed that problem. But I am still stuck with the blending using the alpha value. The blending function I am using does the desired result with the image, but does not seem to use the alpha value. I need something that will do the same effect, but use the alpha so I can set how opaque it is.

Anyone? My particles are making smoke, the smoke is black, if I use the options mentioned, the particle becomes white on the screen. I need it black.

I think what you need is GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA. But this has the disadvantage that you have to sort the particles for a correct result.

What may work is GL_ZERO, GL_ONE_MINUS_SRC_ALPHA. But this is only for black smoke, because the color of the particle is entirely ignored with this blending modeā€¦ It basically darkens the fragment by an amount specified by source alpha. This mode is order independant, no need to sort here.