Hello everyone, I began to get acquainted with the library SFML, run a standard window.
Actually, it is impossible to load a png image into this window, when this process is implemented, a loop occurs and the program hangs.

Here is the code.

RenderWindow window(VideoMode(640, 480), "SFML works!"); CircleShape shape(100.f); shape.setFillColor(sf::Color::Green); /* Image i; i.loadFromFile("image/1232.png"); Texture t; t.loadFromImage(i); // если убрать блок комментария, то стандартное окно запускается. Sprite s; s.setTexture(t); s.setPosition(50, 25); */ while (window.isOpen()) { Event event; while (window.pollEvent(event)) { if (event.type == Event::Closed) window.close(); } window.clear(); window.draw(s); // shape для стандарта. window.display(); } return 0; 
  • one
    Your code won't compile for sure. Give the minimum complete compiled example. - KoVadim
  • It works for me, check the path to the picture. - Gleb

1 answer 1

you do not loop, but "over-polling", the window is updated too often.

when you load a texture, etc., the processor time is limited by the time of the hard disk / memory, when you do not load the texture and do not pause (sleep in a cycle), you just get the fastest possible cycle, the window is polled with all the speed available and it looks hung. or do not even have time to draw