U
U
User7002021-12-25 14:35:42
User interface
User700, 2021-12-25 14:35:42

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();
  }
}

Something like:
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();
      }
    }
  }
}

Or what are the solutions, the libraries are simpler and fairly lightweight (not Qt) for showing a picture in a modal pop-up window (the text is displayed in the console).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lo-lo, 2021-12-27
@Vika_beauty_girl

Look here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question