sf::RenderWindow window(sf::VideoMode(800, 600), "My Window"); while (window.isOpen()) { // game logic and rendering here }
sf::RenderWindow window(sf::VideoMode(800, 600), "My Window"); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) { window.close(); } } // game logic and rendering here }This code creates a window and begins a loop that will continue as long as the window is open. It then has an inner loop that polls for events, such as keyboard presses. If the user presses the escape key, the window is closed by calling the close function on the window object. Package/library: SFML