# How can I debug what is being rendered to a Frame Buffer Object in OpenGL?

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.

• 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. Aug 4 '15 at 20:33
• 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
Aug 7 '15 at 23:18
• 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
– 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.

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