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

Author Topic: Using sf::RenderWindow::Capture() efficiently  (Read 1897 times)

0 Members and 1 Guest are viewing this topic.

Xander314

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://sfmlcoder.wordpress.com/
    • Email
Using sf::RenderWindow::Capture() efficiently
« on: January 10, 2012, 09:48:33 pm »
I noticed today that sf::Image::CopyWindow has been replaced by sf::RenderWindow::Capture().

I wanted to ask how to use this function efficiently, given the performance overhead of copying an image.

Is there something better than this:
Code: [Select]

sf::Image screenshot = Window.Capture();


I know the copy related to the return of an sf::Image can be optimised out, but how can I get around the overhead of the assignment operation?

I suppose I could do this:
Code: [Select]

sf::Image& screenshot = Window.Capture();

but in some circumstances I imagine there would be issues of scope/lifetime of the returned temporary.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Using sf::RenderWindow::Capture() efficiently
« Reply #1 on: January 10, 2012, 10:01:10 pm »
The copy will most likely be optimized, yes. You can't take a reference on the returned image, it's only a temporary that will be destroyed after the call is finished.

But why do you want to store the returned image? What do you do with it?
Laurent Gomila - SFML developer