SFML community forums

Help => Graphics => Topic started by: tmac on July 07, 2008, 10:50:23 pm

Title: [Solved] OpenGL and Capture()
Post by: tmac on July 07, 2008, 10:50:23 pm
Hello

I have a RenderWindow that for now contains only OpenGL rendered graphics. But when I use the screenshot code in the tutorial:

sf::Image Screen = App.Capture();
Screen.SaveToFile("screenshot.jpg");

all I get is a black image. Is Capture() supposed to capture OpenGL graphics? And If I write text using RenderWindow::Draw(), it does not appear in the screenshot either.

Btw, is it possible to save as PNG? I couldn't find anything in the Image class to set the image format.

Debian Sid, SFML1.3

Best regards,
Torquil Sørensen
Title: [Solved] OpenGL and Capture()
Post by: Laurent on July 08, 2008, 02:52:35 am
Quote
all I get is a black image

It captures the current contents of the screen, so it may vary depending on where you locate your call in the main loop. The right place should be between the last Draw and Display.

Quote
Btw, is it possible to save as PNG? I couldn't find anything in the Image class to set the image format.

Yes, PNG is supported. The format is simply deduced from the filename extension.
Title: Thanks
Post by: tmac on July 08, 2008, 11:40:24 am
Thanks, it works fine when I put the command immediately before the Display() as you said. I should have thought of that :-)

Best regards
Torquil Sørensen