Write depthbuffer from texture

Is it ok to capture the depth buffer into a texture once scene is rendered and then just refill it from the texture? Something like this:
gl_FragDepth = texture2D(depthTexture,coords).r;

I am looking for a way to avoid rendering geometry twice just to fill the depth buffer for another op. (I am not using FBO right now).

Thanks

Yes, this is exactly what I do and it works.
With the fragment shader program in use, you will also need the following lines before drawing your depth textured quad:

glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);

Thanks overlay. I have problems though with antialiasing, the edges have some flickering borders containing the previous color from the color buffer. Some subpixels problem. This doesn’t happen of course when doing rendering into depth buffer. I could just clear the color buffer with black to make it less visible but i need a solid solution as it looks extremely horrible when moving the camera.

Maybe http://www.opengl.org/registry/specs/ARB/sample_shading.txt
but I don’t see it explicitly stating that depth can also be tampered with.

After all that bug comes from my application. Depth is not altered in any way. Everything works fine now.