Screenshot of OpenGL context

Moderator
Posts: 522
Joined: 2002.04
Post: #1
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?

Why is capturing a window different than a screen/selection?

-Jon
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
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.

Alex Diener
Quote this message in a reply
Member
Posts: 28
Joined: 2003.10
Post: #3
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.

-- Giles Williams
Oolite - retro space-sim agogo
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #4
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.

-Jon
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #5
It is broken, and Apple knows about it. Feel free to log another bug on it though.

Minimizing, there is an OS event that you can trap and copy the GL bits to the window backing store. Screen capture, there is no OS event, so there's nothing you can do now. Sorry.
Quote this message in a reply
Moderator
Posts: 102
Joined: 2003.07
Post: #6
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 Wink

-CarbonX
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #7
arekkusu Wrote:It is broken, and Apple knows about it. Feel free to log another bug on it though.

Minimizing, there is an OS event that you can trap and copy the GL bits to the window backing store. Screen capture, there is no OS event, so there's nothing you can do now. Sorry.

Thanks, although an unfortunate bug it's good to know it's not my fault!

-Jon
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Full screen context doesn't remain the current context Malarkey 3 3,453 Feb 1, 2007 05:27 PM
Last Post: OneSadCookie
  cocoa for nibbies [OpenGL context creation/ Initializing a PixelFormat] Byron Clarke 7 3,872 Jun 23, 2005 01:23 AM
Last Post: Byron Clarke
  OpenGL screenshot rogue 11 8,318 Sep 30, 2003 09:27 AM
Last Post: MacFiend
  Updating an SDL/OpenGL context... sealfin 2 2,433 Sep 10, 2003 06:13 AM
Last Post: sealfin
  Normal Problem - Screenshot available designdb 8 3,784 May 17, 2003 11:31 AM
Last Post: designdb