From 45bc39a47a731ff9fabc1ad65ce1240604744395 Mon Sep 17 00:00:00 2001 From: Chris Bennight Date: Mon, 28 Sep 2026 14:33:21 -0400 Subject: [PATCH] Fix cli opengl context version (#15745) Co-authored-by: chris Co-authored-by: Ian Bassi --- src/OrcaSlicer.cpp | 21 ++++++++++++++++----- src/slic3r/GUI/OpenGLManager.cpp | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index e7facbdbd8..33411e2f0d 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -7290,9 +7290,9 @@ int CLI::run(int argc, char **argv) colors_out[color_idx] = ColorRGBA(float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, float(rgb_color[3]) / 255.f); } - int gl_major, gl_minor, gl_verbos; - glfwGetVersion(&gl_major, &gl_minor, &gl_verbos); - BOOST_LOG_TRIVIAL(info) << boost::format("opengl version %1%.%2%.%3%")%gl_major %gl_minor %gl_verbos; + int glfw_major, glfw_minor, glfw_revision; + glfwGetVersion(&glfw_major, &glfw_minor, &glfw_revision); + BOOST_LOG_TRIVIAL(info) << boost::format("GLFW version %1%.%2%.%3%") % glfw_major % glfw_minor % glfw_revision; bool thumbnail_opengl_ready = false; glfwSetErrorCallback(glfw_callback); @@ -7304,8 +7304,9 @@ int CLI::run(int argc, char **argv) } else { BOOST_LOG_TRIVIAL(info) << "glfwInit Success."<< std::endl; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, gl_major); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, gl_minor); + // Request OrcaSlicer's minimum OpenGL version, independently of the GLFW library version. + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_RED_BITS, 8); glfwWindowHint(GLFW_GREEN_BITS, 8); glfwWindowHint(GLFW_BLUE_BITS, 8); @@ -7321,6 +7322,16 @@ int CLI::run(int argc, char **argv) #endif GLFWwindow* window = glfwCreateWindow(640, 480, "base_window", NULL, NULL); +#ifndef __WXMAC__ + if (window == NULL) { + // Some drivers (e.g. older Mesa) only expose compatibility profile 3.0; take whatever they offer. + BOOST_LOG_TRIVIAL(warning) << "Failed to create OpenGL 3.3 compatibility context, retrying with driver default" << std::endl; + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); + window = glfwCreateWindow(640, 480, "base_window", NULL, NULL); + } +#endif if (window == NULL) { BOOST_LOG_TRIVIAL(error) << "Failed to create GLFW window; skipping thumbnail rendering for CLI export" << std::endl; diff --git a/src/slic3r/GUI/OpenGLManager.cpp b/src/slic3r/GUI/OpenGLManager.cpp index 382a9176b9..0fc8ce9c6e 100644 --- a/src/slic3r/GUI/OpenGLManager.cpp +++ b/src/slic3r/GUI/OpenGLManager.cpp @@ -286,7 +286,7 @@ bool OpenGLManager::init_gl(bool popup_error) bool valid_version = s_gl_info.is_version_greater_or_equal_to(2, 0); if (!valid_version) { - BOOST_LOG_TRIVIAL(error) << "Found opengl version <= 3.2"<< std::endl; + BOOST_LOG_TRIVIAL(error) << "Found opengl version < 2.0"<< std::endl; // Complain about the OpenGL version. if (popup_error) { wxString message = from_u8((boost::format(