SFML community forums
Help => General => Topic started by: declan 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:
sf::Image::CopyScreen(App,5);
it says
...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!
-
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 ;)
-
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
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?
-
Wow, I feel like an idiot. I looked at my Image.hpp file and it showed the header for CopyScreen():
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);
-
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.
-
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:
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...
-
You can checkout the latest source code from GitHub (https://github.com/SFML/SFML/issues), 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).
-
You can checkout the latest source code from GitHub (https://github.com/SFML/SFML/issues), 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!