| 499 | } |
| 500 | |
| 501 | void run() { |
| 502 | try { |
| 503 | Logger::info("Application: initialization..."); |
| 504 | m_application->applicationInit(make_shared<Controller>(this)); |
| 505 | |
| 506 | Logger::info("Application: renderer initialization..."); |
| 507 | m_application->renderInit(m_renderer); |
| 508 | |
| 509 | Logger::info("Application: main update loop..."); |
| 510 | |
| 511 | m_updateTicker.reset(); |
| 512 | m_renderTicker.reset(); |
| 513 | |
| 514 | bool quit = false; |
| 515 | while (true) { |
| 516 | cleanup(); |
| 517 | |
| 518 | ImGui_ImplOpenGL3_NewFrame(); |
| 519 | ImGui_ImplSDL3_NewFrame(); |
| 520 | ImGui::NewFrame(); |
| 521 | |
| 522 | for (auto const& event : processEvents()) |
| 523 | m_application->processInput(event); |
| 524 | |
| 525 | if (m_platformServices) |
| 526 | m_platformServices->update(); |
| 527 | |
| 528 | if (m_cursorVisible || m_platformServices->overlayActive()) |
| 529 | SDL_ShowCursor(); |
| 530 | else |
| 531 | SDL_HideCursor(); |
| 532 | |
| 533 | int updatesBehind = max<int>(round(m_updateTicker.ticksBehind()), 1); |
| 534 | updatesBehind = min<int>(updatesBehind, m_maxFrameSkip + 1); |
| 535 | for (int i = 0; i < updatesBehind; ++i) { |
| 536 | m_application->update(); |
| 537 | m_updateRate = m_updateTicker.tick(); |
| 538 | } |
| 539 | |
| 540 | m_renderer->startFrame(); |
| 541 | m_application->render(); |
| 542 | m_renderer->finishFrame(); |
| 543 | |
| 544 | ImGui::Render(); |
| 545 | ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); |
| 546 | SDL_GL_SwapWindow(m_sdlWindow); |
| 547 | m_renderRate = m_renderTicker.tick(); |
| 548 | |
| 549 | if (m_quitRequested) { |
| 550 | Logger::info("Application: quit requested"); |
| 551 | quit = true; |
| 552 | } |
| 553 | |
| 554 | if (m_signalHandler.interruptCaught()) { |
| 555 | Logger::info("Application: Interrupt caught"); |
| 556 | quit = true; |
| 557 | } |
| 558 |
no test coverage detected