<p>Components of the default framebuffer do not have an &quot;ID&quot;. You can only use those images as components of the default framebuffer.</p>
<p>If you want to use images in a framebuffer as textures or the like, then you're going to have to create them yourself. You cannot rely on the default framebuffer's images.</p>

CC BY-SA 4.0
2023-03-20T13:51:07.783Z
2023-03-20T13:51:07.783Z
Nicol Bolas
<p>I have an application that uses only the default opengl framebuffer. It is initialized with color and depth buffer.
I want to use the depth buffer as a uniform within a shader to access the current depth values.
How can I make this happen? I tried to get the GLint ID of the depth buffer with the following command:</p>
<pre><code>GLint params;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &amp;params);
std::cout &lt;&lt; &quot;Depthbuffer id:&quot; &lt;&lt; params &lt;&lt; std::endl;
</code></pre>
<p>the output is something like 325462352776. so that doesn't work :(</p>
<p>How can I get the correct ID of the depth buffer so I can use it to read its values in a shader?</p>

<opengl>
OpenGL get default depthbuffer
Thomas
# OpenGL get default depthbuffer

(Asked by: username_0 on 2023-03-20)

I have an application that uses only the default opengl framebuffer. It is initialized with color and depth buffer.
I want to use the depth buffer as a uniform within a shader to access the current depth values.
How can I make this happen? I tried to get the GLint ID of the depth buffer with the following command:

```
GLint params;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params);
std::cout << "Depthbuffer id:" << params << std::endl;

```

the output is something like 325462352776. so that doesn't work :(

How can I get the correct ID of the depth buffer so I can use it to read its values in a shader?

**Tags:** opengl


---

## 1 answers

### Answer by username_1 on 2023-03-20. Score: 2 | Accepted answer

Components of the default framebuffer do not have an "ID". You can only use those images as components of the default framebuffer.

If you want to use images in a framebuffer as textures or the like, then you're going to have to create them yourself. You cannot rely on the default framebuffer's images.


---

