MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / doMainLoop

Method doMainLoop

Engine/source/app/mainLoop.cpp:580–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578}
579
580bool StandardMainLoop::doMainLoop()
581{
582 #ifdef TORQUE_DEBUG
583 if( gStartupTimer )
584 {
585 Con::printf( "Started up in %.2f seconds...",
586 F32( gStartupTimer->getElapsedMs() ) / 1000.f );
587 SAFE_DELETE( gStartupTimer );
588 }
589 #endif
590
591 bool keepRunning = true;
592// while(keepRunning)
593 {
594 tm->setBackgroundThreshold(mClamp(sgBackgroundProcessSleepTime, 1, 200));
595 tm->setForegroundThreshold(mClamp(sgTimeManagerProcessInterval, 1, 200));
596 // update foreground/background status
597 if(WindowManager->getFirstWindow())
598 {
599 static bool lastFocus = false;
600 bool newFocus = ( WindowManager->getFocusedWindow() != NULL );
601 if(lastFocus != newFocus)
602 {
603#ifndef TORQUE_SHIPPING
604 Con::printf("Window focus status changed: focus: %d", newFocus);
605 if (!newFocus)
606 Con::printf(" Using background sleep time: %u", Platform::getBackgroundSleepTime());
607#endif
608
609#ifdef TORQUE_OS_MAC
610 if (newFocus)
611 WindowManager->getFirstWindow()->show();
612
613#endif
614 lastFocus = newFocus;
615 }
616
617 // under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance
618 if (!Platform::getWebDeployment())
619 tm->setBackground(!newFocus);
620 else
621 tm->setBackground(false);
622 }
623 else
624 {
625 tm->setBackground(false);
626 }
627
628 PROFILE_START(MainLoop);
629 Sampler::beginFrame();
630
631 if(!Process::processEvents())
632 keepRunning = false;
633
634 ThreadPool::processMainThreadWorkItems();
635 Sampler::endFrame();
636 ConsoleValue::resetConversionBuffer();
637 PROFILE_END_NAMED(MainLoop);

Callers

nothing calls this directly

Calls 9

printfFunction · 0.85
mClampFunction · 0.85
getElapsedMsMethod · 0.45
getFirstWindowMethod · 0.45
getFocusedWindowMethod · 0.45
showMethod · 0.45
setBackgroundMethod · 0.45

Tested by

no test coverage detected