Fix cli opengl context version (#15745)

Co-authored-by: chris <basque-estate.0b@icloud.com>
Co-authored-by: Ian Bassi <ian.bassi@outlook.com>
This commit is contained in:
Chris Bennight
2026-09-28 15:33:21 -03:00
committed by GitHub
co-authored by chris Ian Bassi
parent d35ea27ea5
commit 1dd57ca72e
2 changed files with 17 additions and 6 deletions
+16 -5
View File
@@ -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;
+1 -1
View File
@@ -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(