Hi,
I'm trying to catch up with last SFML releases, and noticed that RenderWindow::capture is now deprecated:
Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
My use case is saving to a image file what is currently rendered on a render window.
Is the following code the best approach for SFML >= 2.4?
sf::Texture texture;
texture.create(render_window.getSize().x, render_window.getSize().y);
texture.update(render_window);
if (texture.copyToImage().saveToFile(filename))
{
std::cout << "screenshot saved to " << filename << std::endl;
}
Also, this seems like quite a common task. Maybe it should be added in the wiki?