| 614 | #endif |
| 615 | |
| 616 | int Viewer::launch( const LaunchParams& params ) |
| 617 | { |
| 618 | if ( isLaunched_ ) |
| 619 | { |
| 620 | spdlog::error( "Viewer is already launched!" ); |
| 621 | return 1; |
| 622 | } |
| 623 | |
| 624 | // log start line |
| 625 | commandArgs.resize( params.argc ); |
| 626 | for ( int i = 0; i < params.argc; ++i ) |
| 627 | { |
| 628 | commandArgs[i] = std::string( params.argv[i] ); |
| 629 | spdlog::info( "argv[{}]: {}", i, commandArgs[i] ); |
| 630 | } |
| 631 | filterReservedCmdArgs( commandArgs ); |
| 632 | |
| 633 | launchParams_ = params; |
| 634 | isAnimating = params.isAnimating; |
| 635 | animationMaxFps = params.animationMaxFps; |
| 636 | experimentalFeatures = params.developerFeatures; |
| 637 | |
| 638 | bool defaultMultiViewport = Config::instance().getBool( cDefaultMultiViewportKey, true ); |
| 639 | launchParams_.multiViewport = defaultMultiViewport && params.multiViewport; |
| 640 | |
| 641 | auto res = launchInit_( params ); |
| 642 | if ( res != EXIT_SUCCESS ) |
| 643 | return res; |
| 644 | |
| 645 | CommandLoop::setState( CommandLoop::StartPosition::BeforeWindowAppear ); |
| 646 | CommandLoop::processCommands(); // execute pre init commands before first draw |
| 647 | focusRedrawReady_ = true; |
| 648 | |
| 649 | #ifdef _WIN32 |
| 650 | // splash window must be hidden after main window appear, otherwise another application (e.g. Windows Explorer) is activated |
| 651 | if ( params.windowMode == LaunchParams::HideInit && window ) |
| 652 | glfwShowWindow( window ); |
| 653 | #endif |
| 654 | |
| 655 | if ( params.windowMode != LaunchParams::NoWindow && params.windowMode != LaunchParams::Hide && params.splashWindow ) |
| 656 | params.splashWindow->stop(); |
| 657 | |
| 658 | #ifndef _WIN32 |
| 659 | if ( params.windowMode == LaunchParams::HideInit && window ) |
| 660 | glfwShowWindow( window ); |
| 661 | #endif |
| 662 | |
| 663 | CommandLoop::setState( CommandLoop::StartPosition::AfterWindowAppear ); |
| 664 | CommandLoop::processCommands(); // execute remaining commands in the queue, important for params.startEventLoop==false |
| 665 | |
| 666 | if ( params.startEventLoop ) |
| 667 | { |
| 668 | #ifdef __EMSCRIPTEN__ |
| 669 | mainLoopFunc_(); |
| 670 | #else |
| 671 | launchEventLoop(); |
| 672 | #endif |
| 673 | } |
no test coverage detected