mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Fix high CPU usage issue with emscripten demos.
This commit is contained in:
@@ -116,7 +116,8 @@ if ( SceneManager::instance()->getUISceneNode()->invalidated() ) {
|
||||
// Display the scene to the screen.
|
||||
win->display();
|
||||
} else {
|
||||
Sys::sleep( Milliseconds( 8 ) );
|
||||
// For for an input event or timeout after 16ms if has focus, otherwise wait 100ms.
|
||||
win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) );
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -23,9 +23,13 @@ void mainLoop() {
|
||||
// Redraw the UI scene.
|
||||
SceneManager::instance()->draw();
|
||||
|
||||
// Display the scene to the screen.
|
||||
win->display();
|
||||
} else {
|
||||
Sys::sleep( Milliseconds( 8 ) );
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
// For for an input event or timeout after 16ms if has focus, otherwise wait 100ms.
|
||||
win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -478,7 +478,9 @@ void App::mainLoop() {
|
||||
firstFrame = false;
|
||||
}
|
||||
} else {
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
mWindow->getInput()->waitEvent( Milliseconds( mWindow->hasFocus() ? 16 : 100 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( mBenchmarkMode && mSecondsCounter.getElapsedTime() >= Seconds( 1 ) ) {
|
||||
|
||||
@@ -69,7 +69,9 @@ void mainLoop() {
|
||||
|
||||
win->display();
|
||||
} else {
|
||||
Sys::sleep( Milliseconds( 8 ) );
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +93,7 @@ EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
if ( win->isOpen() ) {
|
||||
PixelDensity::setPixelDensity( eemax( win->getScale(), pixelDensity ) );
|
||||
|
||||
win->setCloseRequestCallback( cb::Make1( onCloseRequestCallback ) );
|
||||
win->setCloseRequestCallback( onCloseRequestCallback );
|
||||
|
||||
UISceneNode* uiSceneNode = UISceneNode::New();
|
||||
|
||||
|
||||
@@ -69,7 +69,9 @@ void mainLoop() {
|
||||
|
||||
win->display();
|
||||
} else {
|
||||
Sys::sleep( Milliseconds( 8 ) );
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +93,7 @@ EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
if ( win->isOpen() ) {
|
||||
PixelDensity::setPixelDensity( eemax( win->getScale(), pixelDensity ) );
|
||||
|
||||
win->setCloseRequestCallback( cb::Make1( onCloseRequestCallback ) );
|
||||
win->setCloseRequestCallback( onCloseRequestCallback );
|
||||
|
||||
UISceneNode* uiSceneNode = UISceneNode::New();
|
||||
|
||||
|
||||
@@ -937,7 +937,9 @@ void App::mainLoop() {
|
||||
|
||||
mWindow->display();
|
||||
} else {
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
mWindow->getInput()->waitEvent( Milliseconds( mWindow->hasFocus() ? 16 : 100 ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user