Screenshot of OpenGL context

In my OpenGL game when I take a screenshot of the entire screen using command-shift-3, or a section of the screen using command-shift-4, things work fine. But when I take a screenshot of the window using command-shift-4 + spacebar, the window is a white screen.

Why is this? What do I need to do to fix it?

I'm guessing it is a similar problem to when you minimize an OpenGL window to the dock and get a white screen. But is there a carbon event I can install for this case that will give me a chance to copy things to the screen?

aarku Wrote:Why is capturing a window different than a screen/selection?

Just a guess... Maybe the window capturing mechanism simply copies straight out of the window's PixMap, while the fullscreen/region capture has to use another mechanism to get at the pixels.

What I've seen many OpenGL applications do is implement their own screenshot mechanism with a custom key shortcut, use glReadPixels to get the pixel data, and save that to disk. That's probably the only reliable way to do it, because even with fullscreen capture, tearing can occur.

I don't know, but writing a screenshot from an OpenGL context is a relatively simple task of using glReadPixels to get the data bytes from the screen, arranging them into an NSBitmapImageRep, adding that to an NSImage and then writing out the NSImage.

aegidian Wrote:I don't know, but writing a screenshot from an OpenGL context is a relatively simple task of using glReadPixels to get the data bytes from the screen, arranging them into an NSBitmapImageRep, adding that to an NSImage and then writing out the NSImage.

I could post the code used in Oolite for doing it if you like.

I have my own functions to read the context and write to a GWorld or save to a file, thanks. I'm just trying to get the game behaving with the OS correctly. Command-shift-4 + space doesn't work, and it should.

The problem with Command+Shift+4 Space is that the OpenGL context is constantly updating so here's what I do. Just do a Command+Shift+4 and drag a box arround the window (It is still a bit tricky to get the shot) and you will be able to see the frame changes. It may take a few tries (most of the time you just get partially drawn pics) but it's better than pure white right? good luck