Rendering in an invisible window

I am trying to render in an invisible window and then use glReadPixels to get the pixels from the back buffer (without swapping buffers, of course). It’s a way to do offscreen rendering that avoids some of the complications and limitations of FBOs and pbuffers, though I get the impression that it’s more common on the Mac than on Windows. It works in simple cases, but when I try to use a pixel format that supports multisampling, glReadPixels returns all black pixels. (The alpha byte is set, so I know it’s not just leaving the buffer uninitialized.) Anyone know any special trick to get this to work?

The opengl spec is pretty clear on the fact that pixels on a normal screen framebuffer (not FBO and PBuffer) that are occluded or invisible in any way are undefined.

I have to admit I’m not very familiar with multisample buffers, but what ‘limitations of FBOs’ are you referring to?


Setting up the framebuffer object just needs four or five more instructions… And as Mazy pointed out you mathod won’t work anyway, as the driver just “optimizes” the calls (if region of a window is not visible there is no need to render to it)

Well, there’s the fact that a driver may not support FBOs, or may support FBOs but not with multisampling, or may support FBOs but not a stencil buffer. And then there’s the fact that you can’t use glReadPixels directly from a multisample FBO.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.