MCPcopy Create free account
hub / github.com/cdcseacave/openMVS / Initialize

Method Initialize

apps/Viewer/Window.cpp:84–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84bool Window::Initialize(const cv::Size& size, const String& windowTitle, Scene& scene) {
85 title = windowTitle;
86
87 // Initialize GLFW
88 if (!glfwInit()) {
89 DEBUG("Failed to initialize GLFW");
90 return false;
91 }
92
93 #ifdef __APPLE__
94 // Install macOS file open handler after GLFW initializes
95 OpenMVS_InstallFileHandler();
96 #endif
97
98 // Set GLFW window hints for OpenGL 3.3 Core Profile
99 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
100 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
101 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
102 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
103
104 // Additional window hints
105 glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
106 glfwWindowHint(GLFW_DOUBLEBUFFER, GL_TRUE);
107 glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // Create window initially hidden
108 #if 0
109 glfwWindowHint(GLFW_SAMPLES, 4); // 4x MSAA
110 #endif
111
112 // Create window
113 window = glfwCreateWindow(size.width, size.height, title, nullptr, nullptr);
114 if (!window) {
115 DEBUG("Failed to create GLFW window");
116 glfwTerminate();
117 return false;
118 }
119
120 #ifdef _MSC_VER
121 // Set application icon from resources for both window and taskbar.
122 // Taskbar uses the class big icon; set both big/small and also the class icons.
123 const HINSTANCE hInst = ::GetModuleHandle(NULL);
124 const HWND hwnd = glfwGetWin32Window(window);
125 // Load big and small icons from the same resource (101 added via CMake create_rc_files)
126 hIconBig = (HICON)::LoadImage(hInst, MAKEINTRESOURCE(101), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0);
127 hIconSmall = (HICON)::LoadImage(hInst, MAKEINTRESOURCE(101), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
128 // Set window icons (affects title bar, alt-tab)
129 ::SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIconBig);
130 ::SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall);
131 // Also set the class icons so the taskbar picks it up reliably
132 ::SetClassLongPtr(hwnd, GCLP_HICON, (LONG_PTR)hIconBig);
133 ::SetClassLongPtr(hwnd, GCLP_HICONSM, (LONG_PTR)hIconSmall);
134 #endif
135
136 // Make context current
137 glfwMakeContextCurrent(window);
138
139 // Load OpenGL functions with GLAD
140 if (!gladLoadGL()) {
141 DEBUG("Failed to initialize GLAD");

Callers

nothing calls this directly

Calls 10

setChangeCallbackMethod · 0.80
hasSelectionPathMethod · 0.80
classifyPointCloudMethod · 0.80
classifyMeshMethod · 0.80
setDeleteCallbackMethod · 0.80
IsWorkflowRunningMethod · 0.80
setROICallbackMethod · 0.80
SetROIFromSelectionMethod · 0.80
IsEmptyMethod · 0.45

Tested by

no test coverage detected