MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / launchInit_

Method launchInit_

source/MRViewer/MRViewer.cpp:839–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839int Viewer::launchInit_( const LaunchParams& params )
840{
841 MR_TIMER;
842 CommandLoop::setMainThreadId( std::this_thread::get_id() );
843 spdlog::info( "Log file: {}", utf8string( Logger::instance().getLogFileName() ) );
844 glfwSetErrorCallback( glfw_error_callback );
845
846#if GLFW_VERSION_MAJOR > 3 || ( GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 )
847#if !defined( MRVIEWER_EXPERIMENTAL_WAYLAND_SUPPORT ) && defined( __linux__ )
848 // force to use X11
849 if ( glfwPlatformSupported( GLFW_PLATFORM_X11 ) )
850 glfwInitHint( GLFW_PLATFORM, GLFW_PLATFORM_X11 );
851#endif
852#endif
853
854 if ( !glfwInit() )
855 {
856 spdlog::error( "glfwInit failed" );
857 return EXIT_FAILURE;
858 }
859 spdlog::info( "glfwInit succeeded" );
860
861#if defined( __APPLE__ )
862 // Setting window properties
863 glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE );
864 glfwWindowHint( GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE ); // required for GLFW 3.3
865 hasScaledFramebuffer_ = true;
866#else
867#if GLFW_VERSION_MAJOR > 3 || ( GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 )
868 if ( glfwGetPlatform() == GLFW_PLATFORM_WAYLAND )
869 {
870 glfwWindowHintString( GLFW_WAYLAND_APP_ID, MR_PROJECT_NAME );
871 glfwWindowHint( GLFW_SCALE_FRAMEBUFFER, GLFW_TRUE );
872 hasScaledFramebuffer_ = true;
873 }
874#endif
875#endif
876 glfwWindowHint( GLFW_SAMPLES, getRequiredMSAA_( params.render3dSceneInTexture, false ) );
877#ifndef __EMSCRIPTEN__
878 glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
879 glfwWindowHint( GLFW_FOCUS_ON_SHOW, GLFW_TRUE );
880 glfwWindowHint( GLFW_TRANSPARENT_FRAMEBUFFER, params.enableTransparentBackground );
881#endif
882
883 glfwWindowHint( GLFW_VISIBLE, int( bool( params.windowMode == LaunchParams::Show ) ) );
884 bool windowMode = params.windowMode != LaunchParams::NoWindow;
885
886 if ( windowMode )
887 {
888 alphaSorter_ = std::make_unique<AlphaSortGL>();
889 if ( params.render3dSceneInTexture )
890 sceneTexture_ = std::make_unique<SceneTextureGL>();
891
892 // Create the window
893 if ( !checkOpenGL_( params ) )
894 {
895 if ( params.windowMode == LaunchParams::TryHidden )
896 windowMode = false;

Callers

nothing calls this directly

Calls 8

utf8stringFunction · 0.85
instanceFunction · 0.85
GetSystemInfoJsonFunction · 0.85
getLogFileNameMethod · 0.80
initBackendMethod · 0.80
RecentFilesStoreClass · 0.70
startMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected