I’d like to read the content of the depth buffer in a texture.
That’s what I am assuming:
Setup ReadBuffer, to read from depth buffer (But what is the flag?)
Use glCopyTexImage2D to read it in a texture.
Am I right with this?
You have the right idea, but reading the depth buffer is implied by the data format in the copy call.
Specify a depth internal format for the copy and make sure your texture is of type depth.
You can find the tokens here:
As Dorbie said, if you are using ARB_depth_texture, you need only use CopyTex(Sub)Image2D with a format of DEPTH_COMPONENT.
If you are not using this extension and want depth data in a simple 8-bit luminance texture, then you need to do ReadPixels with a format of DEPTH_COMPONENT, and then Tex(Sub)Image.