| 82 | } |
| 83 | |
| 84 | bool 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"); |
nothing calls this directly
no test coverage detected