Skip to content

Commit

Permalink
Exit faster when window close is requested
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Jul 8, 2024
1 parent 39b47d5 commit d119459
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ int main()
auto window
= sf::RenderWindow(sf::VideoMode({ length, length }), "Mandelbrot", sf::Style::Default ^ sf::Style::Resize);
window.setFramerateLimit(60);
while (window.isOpen()) {
while (true) {
while (const std::optional event = window.pollEvent()) {
if (event->is<sf::Event::Closed>()) {
window.close();
} else if (const auto* key_pressed = event->getIf<sf::Event::KeyPressed>()) {
if (event->is<sf::Event::Closed>())
return 0;

if (const auto* key_pressed = event->getIf<sf::Event::KeyPressed>()) {
switch (key_pressed->scancode) {
case sf::Keyboard::Scan::Escape:
window.close();
break;
return 0;
case sf::Keyboard::Scan::Up:
origin = { origin.real(), origin.imag() + extent / 25 };
break;
Expand Down

0 comments on commit d119459

Please sign in to comment.