I was wondering if it is possible to render my scene onto a depth texture then using that texture for depth testing in another pass. I have an idea to that in shaders, but is that possible hardware-side?
One way to accomplish this would be to use an FBO (Frame Buffer Object) and multiple depth buffers and/or depth textures. A basic use case is shown on the Wiki at OpenGL.org.
Another possible method, maybe applicable to old or very low end hardware could be copying the depth buffer, which you can find an example of using PBOs (Pixel Buffer Objects) here.