Nils
Nils

Reputation: 469

Why is my window closing after some time?

#include <SFML/Graphics.hpp>
    int main(){
sf::RenderWindow window(sf::VideoMode(200, 200), "Title");
while (window.isOpen()) {

    // clear window
    window.clear();

    // Draw here
    
    // end the current frame
    window.display();
}

return 0;
}

Why is it closing after 5 to 10 seconds? When I don't have my cursor inside the window, it won't close.

The 'Error' message is:

The program "[19804] GameDevelopment.exe" was closed with the code -1073741510 (0xc000013a).

Also its giving out

The Thread 0x3308 has ended with the code -1073740777 (0xc0000417).

The Thread 0x36bc has ended with the code -1073740777 (0xc0000417).

The Thread 0x39e4 has ended with the code -1073740777 (0xc0000417).

The Thread 0x32c0 has ended with the code -1073740777 (0xc0000417).

The Thread 0x4ed8 has ended with the code -1073740777 (0xc0000417).

The Thread 0x1408 has ended with the code -1073740777 (0xc0000417).

The Thread 0x2988 has ended with the code -1073740777 (0xc0000417).

The Thread 0x1fb8 has ended with the code -1073740777 (0xc0000417).

The Thread 0x4708 has ended with the code -1073740777 (0xc0000417).

The Thread 0x3808 has ended with the code -1073740777 (0xc0000417).

The Thread 0x21f0 has ended with the code -1073740777 (0xc0000417).

The Thread 0x2620 has ended with the code -1073740777 (0xc0000417).

The Thread 0x135c has ended with the code -1073740777 (0xc0000417).

The Thread 0xca4 has ended with the code -1073740777 (0xc0000417).

The Thread 0x300c has ended with the code -1073740777 (0xc0000417).

The Thread 0x405c has ended with the code -1073740777 (0xc0000417).

The Thread 0xc84 has ended with the code -1073740777 (0xc0000417).

Also interesting is that it works with

   sf::Windw mainwindow(VideoMode(200,200), "Title");

Upvotes: 1

Views: 351

Answers (2)

fallahn
fallahn

Reputation: 31

Your loop is not polling window events which, as stated in the SFML tutorial Bringing the Window to Life, is manditory, highlighted by the red text on the linked page.

Upvotes: 3

Chiranjivee Thakur
Chiranjivee Thakur

Reputation: 140

You need to configure your SFML properly and include all the dependencies on which the Graphics.hpp depends on. The SFML tutorial to configure visual studio is very well explained.

sfml-graphics-s.lib make uses of 

sfml-window-s.lib
sfml-system-s.lib
opengl32.lib
freetype.lib
jpeg.lib

Upvotes: 3

Related Questions