Hi, I would like to save a screenshot of the window but end up with getting a blank image
sf::RenderWindow win(sf::VideoMode(500, 1000), "Window 1");
sf::Texture texture;
sf::Image image;
texture.create(win.getSize().x, win.getSize().y);
texture.update(win);
while (win.isOpen()) {
sf::Event event{};
while (win.pollEvent(event)) {
if (event == sf::Event::Closed) {
win.close();
}
}
win.clear();
win.draw(SomeShape);
image = texture.copyToImage(); // Assign texture to image
image.saveToFile("../Saved Image/Logo.png"); // Able to generate the image file, but it's blank...
win.display();
}
}
I tried to put the two lines with comments at different position, for instance before win.clear or after win.display, but I still got a blank image.