MCPcopy Create free account
hub / github.com/SFML/SFML / run

Method run

examples/vulkan/Vulkan.cpp:2531–2564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2529 }
2530
2531 void run()
2532 {
2533 const sf::Clock clock;
2534
2535 // Start game loop
2536 while (window.isOpen())
2537 {
2538 // Process events
2539 while (const std::optional event = window.pollEvent())
2540 {
2541 // Window closed or escape key pressed: exit
2542 if (event->is<sf::Event::Closed>() ||
2543 (event->is<sf::Event::KeyPressed>() &&
2544 event->getIf<sf::Event::KeyPressed>()->code == sf::Keyboard::Key::Escape))
2545 {
2546 window.close();
2547 }
2548
2549 // Re-create the swapchain when the window is resized
2550 if (event->is<sf::Event::Resized>())
2551 swapchainOutOfDate = true;
2552 }
2553
2554 // Check that window was not closed before drawing to it
2555 if (vulkanAvailable && window.isOpen())
2556 {
2557 // Update the uniform buffer (matrices)
2558 updateUniformBuffer(clock.getElapsedTime().asSeconds());
2559
2560 // Render the frame
2561 draw();
2562 }
2563 }
2564 }
2565
2566private:
2567 // NOLINTBEGIN(readability-identifier-naming)

Callers 2

mainFunction · 0.45
mainFunction · 0.45

Calls 5

drawFunction · 0.85
isOpenMethod · 0.80
getElapsedTimeMethod · 0.80
pollEventMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected