mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 02:41:58 +08:00
SPE-2092: Fixed OpenGL initialization when user specifies invalid value for command line option 'opengl-version'
This commit is contained in:
parent
31ad7375e5
commit
df14f7518d
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user