Answer the question
In order to leave comments, you need to log in
How to display a static image in sfml?
How to display a static image in sfml? Those. do not redraw each time as during animation, but handle the redraw event. When specifying a very low (1--5) frame rate (FPS), the effect of "hanging" appears.
Those. instead of this:
void show()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "Output window");
window.setFramerateLimit(10);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Red);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
}
void show()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "Output window");
window.setFramerateLimit(10);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Red);
while (window.isOpen())
{
sf::Event event;
while (window.waitEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else if (event.type == sf::Event::Repaint) {
window.clear();
window.draw(shape);
window.display();
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question