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.


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 which is both completely free and opensource. Also it is actively supported.

Another one is Intel GPA 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, but it has passed long since the last update. This has evolved into AMD CodeXL that unfortunately I never used.

| improve this answer | |
  • $\begingroup$ 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. $\endgroup$ – Jorge Rodriguez Aug 4 '15 at 20:33
  • $\begingroup$ 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. $\endgroup$ – rys Aug 7 '15 at 23:18
  • $\begingroup$ 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: github.com/GPUOpen-Tools/CodeXL Note that there's a comprehensive list of graphics debugging tools on the apitrace page here: apitrace.github.io/#links $\endgroup$ – Bim Jan 23 '17 at 13:52

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 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.

| improve this answer | |

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.

// XXX WARNING: Untested code follows

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

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

// Blit attachment 0 to the lower-left quadrant of the window
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
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.

| improve this answer | |

Your Answer

