diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2018-06-20 15:34:20 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2018-06-20 15:34:20 +0300 |
commit | 4803e7fc84fd0bdb7edab93a246480bba8725f1e (patch) | |
tree | feaff8230e223bf1d7cf64913aaf57e5e6682b4a /xs | |
parent | 725b8524f2c922dcaa32b280d6553eaba81ae30f (diff) |
Fixed crash at startup on OpenGL 1.1 cards
Diffstat (limited to 'xs')
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 50 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 2 |
2 files changed, 19 insertions, 33 deletions
diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index f288ee456..bdca73854 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -26,33 +26,23 @@ GLCanvas3DManager::GLInfo::GLInfo() { } -bool GLCanvas3DManager::GLInfo::detect() +void GLCanvas3DManager::GLInfo::detect() { const char* data = (const char*)::glGetString(GL_VERSION); - if (data == nullptr) - return false; - - version = data; + if (data != nullptr) + version = data; data = (const char*)::glGetString(GL_SHADING_LANGUAGE_VERSION); - if (data == nullptr) - return false; - - glsl_version = data; + if (data != nullptr) + glsl_version = data; data = (const char*)::glGetString(GL_VENDOR); - if (data == nullptr) - return false; - - vendor = data; + if (data != nullptr) + vendor = data; data = (const char*)::glGetString(GL_RENDERER); - if (data == nullptr) - return false; - - renderer = data; - - return true; + if (data != nullptr) + renderer = data; } bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const @@ -94,10 +84,10 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten std::string line_end = format_as_html ? "<br>" : "\n"; out << h2_start << "OpenGL installation" << h2_end << line_end; - out << b_start << "GL version: " << b_end << version << line_end; - out << b_start << "Vendor: " << b_end << vendor << line_end; - out << b_start << "Renderer: " << b_end << renderer << line_end; - out << b_start << "GLSL version: " << b_end << glsl_version << line_end; + out << b_start << "GL version: " << b_end << (version.empty() ? "N/A" : version) << line_end; + out << b_start << "Vendor: " << b_end << (vendor.empty() ? "N/A" : vendor) << line_end; + out << b_start << "Renderer: " << b_end << (renderer.empty() ? "N/A" : renderer) << line_end; + out << b_start << "GLSL version: " << b_end << (glsl_version.empty() ? "N/A" : glsl_version) << line_end; if (extensions) { @@ -195,15 +185,11 @@ void GLCanvas3DManager::init_gl() if (!m_gl_initialized) { glewInit(); - if (m_gl_info.detect()) - { - const AppConfig* config = GUI::get_app_config(); - m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1"); - m_use_VBOs = !m_use_legacy_opengl && m_gl_info.is_version_greater_or_equal_to(2, 0); - m_gl_initialized = true; - } - else - throw std::runtime_error(std::string("Unable to initialize OpenGL driver\n")); + m_gl_info.detect(); + const AppConfig* config = GUI::get_app_config(); + m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1"); + m_use_VBOs = !m_use_legacy_opengl && m_gl_info.is_version_greater_or_equal_to(2, 0); + m_gl_initialized = true; } } diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 6989da791..3092925d3 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -35,7 +35,7 @@ class GLCanvas3DManager GLInfo(); - bool detect(); + void detect(); bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const; std::string to_string(bool format_as_html, bool extensions) const; |