Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] OpenGL and Capture()  (Read 1817 times)

0 Members and 1 Guest are viewing this topic.

tmac

  • Guest
[Solved] OpenGL and Capture()
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Solved] OpenGL and Capture()
« Reply #1 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.
Laurent Gomila - SFML developer

tmac

  • Guest
Thanks
« Reply #2 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