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

Method doMainLoop

Engine/source/app/mainLoop.cpp:570–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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