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

Author Topic: sf::Image::CopyScreen() not in sf::Image??  (Read 3737 times)

0 Members and 1 Guest are viewing this topic.

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
sf::Image::CopyScreen() not in sf::Image??
« on: August 11, 2011, 04:46:01 pm »
Hi, I'm very confused. I want to take a screenshot several times in my program. I'm using SFML2, so I discovered that they don't use Capture() anymore.

From [url = http://www.sfml-dev.org/forum/viewtopic.php?p=31491&sid=99742a8c296d8c942218806680bef595]this[/url] thread, the guy said to use sf::Image::CopyScreen().  But when I go to the link for sf::Image (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Image.php), it's nowhere to be seen!

So, does it still exist? Because it's not in the documentation, I don't know what arguments to supply it. When I try some silly thing just to see the output, like:

Code: [Select]
sf::Image::CopyScreen(App,5);

it says

Code: [Select]
...candidate is:
/usr/include/SFML/Graphics/Image.hpp:233:10: note: bool sf::Image::CopyScreen(sf::RenderWindow&, const IntRect&)


I'm not really sure what an IntRect is, or how I will save the screenshot to an sf::Image. It was so much easier with App.Capture, why'd they change it?

Can anyone help me?

Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Image::CopyScreen() not in sf::Image??
« Reply #1 on: August 11, 2011, 04:53:01 pm »
SFML 2 changes a lot, so don't trust older topics, only the online documentation is reliable (assuming you use the latest snapshot -- it you use an older one you can only rely on headers).

So if you have a recent revision (not more than a few days old), RenderWindow::Capture is back.

If you have an older revision (which should be the case since your compiler still finds Image::CopyScreen), read the documentation (in Image.hpp directly) of Image::CopyScreen. I don't know what your "5" is supposed to be, but it's not a rectangle ;)
Laurent Gomila - SFML developer

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
sf::Image::CopyScreen() not in sf::Image??
« Reply #2 on: August 11, 2011, 05:17:38 pm »
Quote from: "Laurent"
SFML 2 changes a lot, so don't trust older topics, only the online documentation is reliable (assuming you use the latest snapshot -- it you use an older one you can only rely on headers).

So if you have a recent revision (not more than a few days old), RenderWindow::Capture is back.

If you have an older revision (which should be the case since your compiler still finds Image::CopyScreen), read the documentation (in Image.hpp directly) of Image::CopyScreen. I don't know what your "5" is supposed to be, but it's not a rectangle ;)


Thanks for the swift response!

I'm using "sfml1.99" which is Arch's package for it. From another thread I read here it seems that it is an alpha version of SFML 2.

RenderWindow::Capture definitely doesn't work. If I try App.Capture(), it says

Code: [Select]
error: class 'sf::RenderWindow' has no member named "Capture'

So it's not that. But it recognizes some sort of CopyScreen, so I guess I'll have to use that.

Haha, I just did 5 because I wanted to have two arguments, and see what it gave me. Why do I have to supply a Rect? What is that rect, the area it is capturing?

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
sf::Image::CopyScreen() not in sf::Image??
« Reply #3 on: August 11, 2011, 05:28:36 pm »
Wow, I feel like an idiot. I looked at my Image.hpp file and it showed the header for CopyScreen():

Code: [Select]
bool CopyScreen(RenderWindow& window, const IntRect& sourceRect = IntRect(0, 0, 0, 0));

There is a default Rect, so I don't need to supply one. Herp derp!

myImage.CopyScreen(App);

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
sf::Image::CopyScreen() not in sf::Image??
« Reply #4 on: August 11, 2011, 09:37:34 pm »
Why don't you just use the latest SFML 2 Git revision? Then you don't have to port a lot of code when SFML 2 is finally released.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
sf::Image::CopyScreen() not in sf::Image??
« Reply #5 on: August 12, 2011, 07:57:29 pm »
Quote from: "Nexus"
Why don't you just use the latest SFML 2 Git revision? Then you don't have to port a lot of code when SFML 2 is finally released.


Errr, I'm sorry, I don't know what that means...

If I do pacman -Qi sfml, it gives me:

Version        : 1.99.git20110728-1

What exactly do you mean?

Also, very strangely, at my work computer, I have the same exact version with Arch Linux, and my code is working fine. When I try the same code at home (with the same version of SFML), it is giving me errors:

Code: [Select]
undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::WindowSettings const&)'


Strange...

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
sf::Image::CopyScreen() not in sf::Image??
« Reply #6 on: August 12, 2011, 08:34:51 pm »
You can checkout the latest source code from GitHub, so you have access to the newest features and bugfixes.

I thought you would use an older version, but it seems like it is quite up-to-date, too (2011-07-28). I am not used to Arch Linux and its packaging system, I have always used Git directly (on Windows and Ubuntu).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

declan

  • Newbie
  • *
  • Posts: 34
    • View Profile
sf::Image::CopyScreen() not in sf::Image??
« Reply #7 on: August 13, 2011, 09:36:07 pm »
Quote from: "Nexus"
You can checkout the latest source code from GitHub, so you have access to the newest features and bugfixes.

I thought you would use an older version, but it seems like it is quite up-to-date, too (2011-07-28). I am not used to Arch Linux and its packaging system, I have always used Git directly (on Windows and Ubuntu).


Yeah, that's why I'm confused. Arch's main thing is being "cutting edge", which is cool, but sometimes a huge PITA.

Any idea why it's not compiling for me? I'm compiling with the -l flags. In fact, I'm using the same exact code and makefile, and both systems have the same exact version of SFML. Any ideas?

Thanks!

 

anything