<p>I tested several applications/APIs/libraries to get data from FBOs in applications which use gbuffer for example. After months of suffering I discovered <a href="https://apitrace.github.io/">apitrace</a> available on Github to debug OpenGL, Direct3D and WebGL. I used in Windows and Linux without problems.</p>

<p>I hope that could be useful for you.</p>

CC BY-SA 3.0
2015-08-06T04:25:20.727Z
2015-08-06T04:28:51.917Z
2015-08-06T04:28:51.917Z
esmitt
<p>In addition to cifz's response, another way to visualise FBOs which doesn't cost very much code is to use glBlitFramebuffer() to transfer pixels from a framebuffer to a window.</p>

<pre><code>// XXX WARNING: Untested code follows

// Blit from fbo...
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
// ...to the front buffer.
glBindFramebuffer(GL_WRITE_FRAMEBUFFER, GL_FRONT);

GLsizei HalfWindowWidth = (GLsizei)(WindowWidth / 2.0f);
GLsizei HalfWindowHeight = (GLsizei)(WindowHeight / 2.0f);

// Blit attachment 0 to the lower-left quadrant of the window
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBlitFramebuffer(0, 0, FboWidth, FboHeight,
                  0, 0, HalfWindowWidth, HalfWindowHeight,
                  GL_COLOR_BUFFER_BIT, GL_LINEAR);

// Blit attachment 1 to the lower-right quadrant of the window
glReadBuffer(GL_COLOR_ATTACHMENT1);
glBlitFramebuffer(0, 0, FboWidth, FboHeight,
                  HalfWindowWidth, 0, WindowWidth, HalfWindowHeight,
                  GL_COLOR_BUFFER_BIT, GL_LINEAR);

// ...and so on. You can switch FBOs if you have more than one to read from.
</code></pre>

<p>There are a few obvious "gotchas", in that HDR buffers probably won't visualise the way you expect them to, you probably can't "see" depth/stencil buffers in the obvious way, and if the size of the FBO doesn't match the area being blitted to, the magnification/minification method might be extremely naive.</p>

<p>But as quick 'n dirty hacks go, it's pretty good.</p>

CC BY-SA 3.0
2015-08-04T23:43:22.107Z
2015-08-05T00:26:44.483Z
2015-08-05T00:26:44.483Z
Pseudonym
<p>Generally to see what is being rendered in the various steps of your pipeline I'd suggest the use of a tool for frame analysis. These usually provide you with a view on the content of each buffer for each API call and this can help you in your situation.</p>

<p>A very good one is <a href="https://github.com/baldurk/renderdoc">Renderdoc</a> which is both completely free and opensource. Also it is actively supported. </p>

<p>Another one is <a href="https://software.intel.com/en-us/gpa/details">Intel GPA</a> that unfortunately, according to its webpage, support up to OGL 3.3 Core. </p>

<p>Just for the sake of adding one more, I used to use <a href="http://www.gremedy.com/">gDEBugger</a>, but it has passed long since the last update. This has evolved into <a href="http://developer.amd.com/tools-and-sdks/opencl-zone/codexl/">AMD CodeXL</a> that unfortunately I never used.</p>

CC BY-SA 3.0
2017-01-23T13:52:24.060Z
I still use gDEbugger from time to time for older GL versions. CodeXL is the more modern version of it and can be found here: https://github.com/GPUOpen-Tools/CodeXL
Note that there's a comprehensive list of graphics debugging tools on the apitrace page here: https://apitrace.github.io/#links
Bim
CC BY-SA 3.0
2015-08-04T20:33:29.797Z
Additionally I also sometimes have a command that will dump a specified fbo out to an image when I press a key. It's the low-tech way.
Jorge Rodriguez
CC BY-SA 3.0
2015-08-07T23:18:31.293Z
It's also probably a good idea to make sure you have the right depth test setup, for the rendering going into your visualisation FBO.
rys
CC BY-SA 3.0
2015-08-04T20:15:17.410Z
2015-08-04T21:18:32.987Z
2015-08-04T21:18:32.987Z
cifz
<p>I have a point cloud that is being rendered to the screen. Each point has its position and color as well as an ID.</p>

<p>I was asked to render the IDs for each point to a texture so I created a FBO and attached two textures, one for color and one for depth. I created the necessary VAO and VBO for this off-screen rendering and uploaded for each point its position and ID.</p>

<p>Once the rendering to the FBO is done, I read the pixels of the color-texture with <code>glReadPixels()</code> to see what the values are, but they seem to be all cleared out, i.e., the value they have is the same as <code>glClearColor()</code>.</p>

<p>Is there a way I can debug what it is being render to the color texture of my FBO? Any tips that you may provide are very welcomed.</p>

<opengl><debugging>
How can I debug what is being rendered to a Frame Buffer Object in OpenGL?
BRabbit27
# How can I debug what is being rendered to a Frame Buffer Object in OpenGL?

(Asked by: username_0 on 2015-08-04)

I have a point cloud that is being rendered to the screen. Each point has its position and color as well as an ID.

I was asked to render the IDs for each point to a texture so I created a FBO and attached two textures, one for color and one for depth. I created the necessary VAO and VBO for this off-screen rendering and uploaded for each point its position and ID.

Once the rendering to the FBO is done, I read the pixels of the color-texture with `glReadPixels()` to see what the values are, but they seem to be all cleared out, i.e., the value they have is the same as `glClearColor()`.

Is there a way I can debug what it is being render to the color texture of my FBO? Any tips that you may provide are very welcomed.

**Tags:** opengl, debugging


---

## 3 answers

### Answer by username_3 on 2015-08-04. Score: 21 | Accepted answer

Generally to see what is being rendered in the various steps of your pipeline I'd suggest the use of a tool for frame analysis. These usually provide you with a view on the content of each buffer for each API call and this can help you in your situation.

A very good one is [Renderdoc](https://github.com/baldurk/renderdoc) which is both completely free and opensource. Also it is actively supported.

Another one is [Intel GPA](https://software.intel.com/en-us/gpa/details) that unfortunately, according to its webpage, support up to OGL 3.3 Core.

Just for the sake of adding one more, I used to use [gDEBugger](http://www.gremedy.com/), but it has passed long since the last update. This has evolved into [AMD CodeXL](http://developer.amd.com/tools-and-sdks/opencl-zone/codexl/) that unfortunately I never used.

> **Comments:**
> **username_5**: Additionally I also sometimes have a command that will dump a specified fbo out to an image when I press a key. It's the low-tech way.  
> **username_6**: It's also probably a good idea to make sure you have the right depth test setup, for the rendering going into your visualisation FBO.  
> **username_4**: I still use gDEbugger from time to time for older GL versions. CodeXL is the more modern version of it and can be found here: https://github.com/GPUOpen-Tools/CodeXL Note that there's a comprehensive list of graphics debugging tools on the apitrace page here: https://apitrace.github.io/#links  

---

### Answer by username_1 on 2015-08-06. Score: 11

I tested several applications/APIs/libraries to get data from FBOs in applications which use gbuffer for example. After months of suffering I discovered [apitrace](https://apitrace.github.io/) available on Github to debug OpenGL, Direct3D and WebGL. I used in Windows and Linux without problems.

I hope that could be useful for you.


---

### Answer by username_2 on 2015-08-04. Score: 7

In addition to username_3's response, another way to visualise FBOs which doesn't cost very much code is to use glBlitFramebuffer() to transfer pixels from a framebuffer to a window.

```
// XXX WARNING: Untested code follows

// Blit from fbo...
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
// ...to the front buffer.
glBindFramebuffer(GL_WRITE_FRAMEBUFFER, GL_FRONT);

GLsizei HalfWindowWidth = (GLsizei)(WindowWidth / 2.0f);
GLsizei HalfWindowHeight = (GLsizei)(WindowHeight / 2.0f);

// Blit attachment 0 to the lower-left quadrant of the window
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBlitFramebuffer(0, 0, FboWidth, FboHeight,
                  0, 0, HalfWindowWidth, HalfWindowHeight,
                  GL_COLOR_BUFFER_BIT, GL_LINEAR);

// Blit attachment 1 to the lower-right quadrant of the window
glReadBuffer(GL_COLOR_ATTACHMENT1);
glBlitFramebuffer(0, 0, FboWidth, FboHeight,
                  HalfWindowWidth, 0, WindowWidth, HalfWindowHeight,
                  GL_COLOR_BUFFER_BIT, GL_LINEAR);

// ...and so on. You can switch FBOs if you have more than one to read from.

```

There are a few obvious "gotchas", in that HDR buffers probably won't visualise the way you expect them to, you probably can't "see" depth/stencil buffers in the obvious way, and if the size of the FBO doesn't match the area being blitted to, the magnification/minification method might be extremely naive.

But as quick 'n dirty hacks go, it's pretty good.


---

