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

Method run

source/application/StarMainApplication_sdl.cpp:501–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

runMainApplicationFunction · 0.45

Calls 15

roundFunction · 0.85
errorFunction · 0.85
overlayActiveMethod · 0.80
ticksBehindMethod · 0.80
startFrameMethod · 0.80
finishFrameMethod · 0.80
spareTimeMethod · 0.80
fatalExceptionFunction · 0.50
outputExceptionFunction · 0.50
applicationInitMethod · 0.45
renderInitMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected