| 396 | } |
| 397 | |
| 398 | void AppImplLinux::run() |
| 399 | { |
| 400 | mApp->privateSetup__(); |
| 401 | mSetupHasBeenCalled = true; |
| 402 | |
| 403 | // quit() was called from setup() |
| 404 | if( mShouldQuit ) |
| 405 | goto terminate; |
| 406 | |
| 407 | // issue initial app activation event |
| 408 | mApp->emitDidBecomeActive(); |
| 409 | |
| 410 | // isse initial resize revent |
| 411 | for( auto &window : mWindows ) { |
| 412 | window->resize(); |
| 413 | } |
| 414 | |
| 415 | // initialize our next frame time |
| 416 | mNextFrameTime = getElapsedSeconds(); |
| 417 | |
| 418 | while( ! mShouldQuit ) { |
| 419 | // update and draw |
| 420 | mApp->privateUpdate__(); |
| 421 | for( auto &window : mWindows ) { |
| 422 | if( mShouldQuit ) // test for quit() issued from update() or draw() |
| 423 | goto terminate; |
| 424 | window->draw(); |
| 425 | } |
| 426 | |
| 427 | glfwPollEvents(); |
| 428 | |
| 429 | // Sleep until the next frame |
| 430 | sleepUntilNextFrame(); |
| 431 | |
| 432 | // Check if a window should be closed / destroyed or if we should exit. |
| 433 | auto shouldCloseWindow = [ this ] ( WindowImplLinux* window ) { |
| 434 | if( ::glfwWindowShouldClose( window->getNative() ) ) { |
| 435 | window->getWindow()->emitClose(); |
| 436 | ::glfwDestroyWindow( window->getNative() ); |
| 437 | return true; |
| 438 | } |
| 439 | return false; |
| 440 | }; |
| 441 | |
| 442 | mWindows.remove_if( shouldCloseWindow ); |
| 443 | if( mWindows.empty() && mQuitOnLastWindowClosed ) |
| 444 | mShouldQuit = true; |
| 445 | } |
| 446 | |
| 447 | terminate: |
| 448 | mApp->emitCleanup(); |
| 449 | // Destroy the main window - this should resolve to |
| 450 | // a call for ::glfwDestroyWindow( ... ); |
| 451 | mMainWindow.reset(); |
| 452 | } |
| 453 | |
| 454 | WindowImplLinux* AppImplLinux::findSharedRendererWindow( const RendererRef &searchRenderer ) |
| 455 | { |
no test coverage detected