Creating a depth texture to use in GLSL

I’m trying to figure out how to create a depth texture that I can use from frame to frame in C++ / GLSL.

Lets say on frame number one I set gl_FragDepth of a few random pixels to 0.5. Before rendering frame 2, I’d like to apply the depth state to a texture. This way, in frame 2, I can determine which texels are at 0.5 so I can further manipulate them.

I can’t seem to find any clear tutorials/reference/instructions on how to do this.

Assuming input from your previous thread is valid, you aren’t really using the depth value for actual depth comparison. So it doesn’t need to be a depth texture at all; it can just be a floating-point texture that you write a value to.

In either case however, what you’re looking for is direct rendering to a texture. To do that, you need to use Framebuffer Objects.

Thank you! Exactly what I’m looking for.

And you’re right… I really just need numbers to compare. Depth seemed like the natural thing to use.