diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index 44f1c28d34..79bb8b6f95 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -190,8 +190,13 @@ int CLI::run(int argc, char **argv) if (semver.has_value() && (*semver) >= opengl_minimum ) { opengl_version.first = semver->maj(); opengl_version.second = semver->min(); + if (std::find(Slic3r::GUI::OpenGLVersions::core.begin(), Slic3r::GUI::OpenGLVersions::core.end(), std::make_pair(opengl_version.first, opengl_version.second)) == Slic3r::GUI::OpenGLVersions::core.end()) { + opengl_version = { 0, 0 }; + boost::nowide::cerr << "Required OpenGL version " << opengl_version_str << " not recognized.\n Option 'opengl-version' ignored." << std::endl; + } } else - boost::nowide::cerr << "Required OpenGL version " << opengl_version_str << " is invalid. Must be greater than or equal to " << opengl_minimum.to_string() << std::endl; + boost::nowide::cerr << "Required OpenGL version " << opengl_version_str << " is invalid. Must be greater than or equal to " << + opengl_minimum.to_string() << "\n Option 'opengl-version' ignored." << std::endl; start_gui = true; m_actions.erase(it); } diff --git a/src/slic3r/GUI/OpenGLManager.cpp b/src/slic3r/GUI/OpenGLManager.cpp index c9df0caaa6..003538266c 100644 --- a/src/slic3r/GUI/OpenGLManager.cpp +++ b/src/slic3r/GUI/OpenGLManager.cpp @@ -458,7 +458,8 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas) const int gl_major = required_opengl_version.first; const int gl_minor = required_opengl_version.second; - const bool supports_core_profile = (gl_major < 3) ? false : (gl_major > 3) ? true : gl_minor >= 2; + const bool supports_core_profile = + std::find(OpenGLVersions::core.begin(), OpenGLVersions::core.end(), std::make_pair(gl_major, gl_minor)) != OpenGLVersions::core.end(); if (gl_major == 0 && !enable_compatibility_profile) { // search for highest supported core profile version @@ -513,9 +514,15 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas) } } - if (m_context == nullptr) - // no valid context was created - throw Slic3r::RuntimeError("Unable to create context for OpenGL."); + if (m_context == nullptr) { + wxGLContextAttrs attrs; + attrs.PlatformDefaults(); + if (m_debug_enabled) + attrs.DebugCtx(); + attrs.EndList(); + // if no valid context was created use the default one + m_context = new wxGLContext(&canvas, nullptr, &attrs); + } #else m_context = new wxGLContext(&canvas); #endif // ENABLE_OPENGL_ES