Hiding a particle stream behind an object

I am working on a space shooter and right now I am trying to make my jumpgate effect look right.

The jumpgates consists on a ring with a particle stream comming out of the center. I am blending my particles so that they look right with each other and disabling depth testing which makes the whole particle system look right (no black squares).

Basicaly I am following the instructions found in most particle system tutorial and on this board.

My problem is that the particles can be seen through the jumpgate ring and also through ships passing in front of the jumpgate. Leaving depth testing enabled solves this problem but then the particles are drawn wrong.

I tried drawing the particles before eveything and by changing glDepthFunc for the particles to GL_ALWAYS it works but now the particles are not blended with the background.

Help!

Draw the particles after drawing everything else, with the depth buffer on. Just set glDepthMask(GL_FALSE) before you draw them and glDepthMask(GL_TRUE) after you are done.

j

Also, sort the particles in back-to-front order and draw them that way.

Thank you, glDepthMask did the trick.