| 369 | } |
| 370 | |
| 371 | void WindowSplash::initGLFW() { |
| 372 | glfwSetErrorCallback([](int errorCode, const char *desc) { |
| 373 | bool isWaylandError = errorCode == GLFW_PLATFORM_ERROR; |
| 374 | #if defined(GLFW_FEATURE_UNAVAILABLE) |
| 375 | isWaylandError = isWaylandError || (errorCode == GLFW_FEATURE_UNAVAILABLE); |
| 376 | #endif |
| 377 | isWaylandError = isWaylandError && std::string_view(desc).contains("Wayland"); |
| 378 | |
| 379 | if (isWaylandError) { |
| 380 | // Ignore error spam caused by Wayland not supporting moving or resizing |
| 381 | // windows or querying their position and size. |
| 382 | return; |
| 383 | } |
| 384 | |
| 385 | s_lastGlfwError.errorCode = errorCode; |
| 386 | s_lastGlfwError.desc = std::string(desc); |
| 387 | log::error("GLFW Error [{:05X}] : {}", errorCode, desc); |
| 388 | }); |
| 389 | |
| 390 | #if defined(OS_LINUX) |
| 391 | #if defined(GLFW_WAYLAND_APP_ID) |
| 392 | glfwWindowHintString(GLFW_WAYLAND_APP_ID, "imhex"); |
| 393 | #endif |
| 394 | |
| 395 | #if defined(GLFW_SCALE_FRAMEBUFFER) |
| 396 | glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_TRUE); |
| 397 | #endif |
| 398 | |
| 399 | glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); |
| 400 | #elif defined(OS_MACOS) |
| 401 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); |
| 402 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); |
| 403 | |
| 404 | glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE); |
| 405 | glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, GLFW_TRUE); |
| 406 | #endif |
| 407 | |
| 408 | // Make splash screen non-resizable, undecorated and transparent |
| 409 | glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); |
| 410 | glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); |
| 411 | glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); |
| 412 | glfwWindowHint(GLFW_FLOATING, GLFW_FALSE); |
| 413 | glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); |
| 414 | |
| 415 | // Create the splash screen window |
| 416 | m_window = glfwCreateWindow(WindowSize.x, WindowSize.y, "Starting ImHex...", nullptr, nullptr); |
| 417 | if (m_window == nullptr) { |
| 418 | hex::showErrorMessageBox(fmt::format( |
| 419 | "Failed to create GLFW window: [{}] {}.\n" |
| 420 | "You may not have a renderer available.\n" |
| 421 | "The most common cause of this is using a virtual machine\n" |
| 422 | "You may want to try a release artifact ending with 'NoGPU'" |
| 423 | , s_lastGlfwError.errorCode, s_lastGlfwError.desc)); |
| 424 | std::exit(EXIT_FAILURE); |
| 425 | } |
| 426 | |
| 427 | ImHexApi::System::impl::setMainWindowHandle(m_window); |
| 428 |
no test coverage detected