views:

37

answers:

1

On a MAC OS X machine, I am using FBO, depth RBO and texture RBO with freeglut to render a 3D scene to FBO and doing a render to texture. All using standard glut functions and glutMainLoop at the end.

I am using glReadPixels to read from the FBO. I can see that the pixels are being read correctly.

However When I hide the glut window using glutHideWindow, I find that the entire buffer which is retrned by glReadPixels is set to clear color (ff 00 00 00). I don't change anything else. I think that the FBO is not being rendered to at all when the window is hidden. How do I change this? This is being observed on MAC OS X. Please let me know if you want to look at the code.

+1  A: 

The window can not be covered, or the buffer will not be updated. The solution is to render to the offscreen buffer (if your card supports it). Otherwise, keep the window above others, otherwise the buffer will be invalid.

EDIT : this has to do with window system, and not with opengl

VJo
any avaliable examples of render to offscreen buffer?
John Qualis
Also, how do I set the window system in OS X in this case so it is updated? I am using glut.
John Qualis
Sorry, I don't know for OS X, but for linux it is not supported. For off screen rendering, this might help http://stackoverflow.com/questions/214437/opengl-fast-off-screen-rendering If pbuffers are supported by your card, then you can use that.
VJo
Off screen rendering with FBOs works but only if window is displayed. OSX Gurus?
John Qualis
Actually it has to do with OpenGL, it's called the "pixel ownership test" and it's defined in the GL spec.
Matias Valdenegro
Hmmmm.. How will this help my case? Does OS X not store the pixel data at all? There's no hope in that case. Here's what I found - "The Pixel Ownership test varies from one OpenGL implementation to the next. Some OpenGL implementations store obscured regions of a window, or the entire window, in an off-screen buffer. Such an implementation can return valid pixel data for an obscured window. However, many OpenGL implementations map pixels on the screen one-to-one to framebuffer storage locations and don't store (and can't return) pixel data for obscured regions of a window."
John Qualis