Can depth value be rendered into texture (Solved)

I found an article through this link:
OpenGL Framebuffer tutorial

there is a sentence says “A renderbuffer are just objects which are used to support offscreen rendering, often for sections of the framebuffer which don’t have a texture format associated with them such as the stencil or depth buffer.”

Why framebuffer does not have a texture format associated with depth buffer? Does this mean I cannot render depth to texture directly using a framebuffer?

Yes you can attach a texture object (TO) as the depth buffer of an FBO.

Depending on the generation/capabilities of the OpenGL implementation () on your system, it might be possible or not.

Look at this other tutorial, it does not say there is such restriction:

Same for the OpenGL spec: section 4.4 page 319.

You can use attach a TO to the depth buffer of an FBO to bake a shadow map, for example.

That tutorial quote was misleading. The idea for renderbuffers is this.

Let’s say you want to render to a texture. But you probably also want a depth buffer and maybe a stencil buffer too. You could create a texture with such formats and attach that to the FBO, but some implementations don’t support some combinations of depth and stencil buffers. Also, using a texture for something like that is overkill. So you can use a renderbuffer with those formats instead.