Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Tirhakah

macrumors newbie
Original poster
Mar 7, 2009
3
0
I've written a project using SDL, and for the testing section of the evaluation I need many screenshots of it. I've been using the built-in mac screencapture (cmd-shift-4), but the default mode (click & drag to select area) means that I need to crop each image to the window borders. I'd far rather use the alternative mode (spacebar to select the whole window), but strangely when I try that I just get a blank window, attached below.
My question is whether there exists any easy way to get the SDL surfaces to display in the screenshot properly. I've found a couple of ways to output the current screen buffer using SDL, but most of them seem to depend on SDL libraries not easily available for the mac. Also, some of the actions that I need to demonstrate testing (such as resizing the window) wouldn't come across so easily this way.

(note: yes this is for a school project, but as this doesn't affect the function of the project my tutor confirms it's fine to request help)
 

Attachments

  • Picture 6.png
    Picture 6.png
    39.2 KB · Views: 211

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Every time you take a screenshot it comes out blank? Even when taking the entire screen? I'm guessing SDL draws via OpenGL, but screenshots should work with OpenGL. I wonder if SDL is using a weird mode that isn't supported by Apple's screenshot tool. You could try the screencapture command-line tool but I'm guessing that is what Apple uses when taking screenshots via the keyboard.
 

Tirhakah

macrumors newbie
Original poster
Mar 7, 2009
3
0
When I take the whole screen, or a selection that includes the SDL window, it all shows up fine. Unfortunately, as I need roughly 60 or so screenshots that means I'd need to crop each of those to include just the window, so I was trying to save time by taking advantage of the feature in screencapture that allows you to capture just the window that the mouse is over, and it's the pictures that come from this that are turning out blank (or rather the edges of the window and the shadow are there, as above, it's just the SDL content that is missing)
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I'm guessing the keyboard commands do the same thing, but have you tried getting a window with grab?

-Lee
 

Tirhakah

macrumors newbie
Original poster
Mar 7, 2009
3
0
Just tested with all three: terminal commands, keyboard shortcuts and grab. Any mode which includes more than one window works fine; I guess that it takes the info from the screen's display buffer. However, in all three, trying to capture just the window I need comes up blank.
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
Well as a kind of workaround you can capture the entire screen for now and keep the window you want centered. Then afterwords use Automator to do the cropping for you. I've done this before and it worked nicely. That way you won't have to manually crop them yourself. Just make sure to keep the window being captured in the same spot.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi Tirhakah

You might be better off putting the capture directly into your app and activating it through a key combination or something like that. If you're using OpenGL then it's simply a matter of reading pixels directly, glReadPixels(), from your front buffer and then saving them out to a file. If you're not using OpenGL then you can read the screen directly. There is a sample project on the Apple dev site which shows you how to implement a screen capture utility. Sorry I can't remember the name of the project, but one of the files is called OpenGLScreenReader.m/.h. Ah, and yes, you use OpenGL to do the reading!

b e n
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.