Fixed crash at startup on OpenGL 1.1 cards
This commit is contained in:
parent
725b8524f2
commit
4803e7fc84
2 changed files with 19 additions and 33 deletions
|
@ -26,33 +26,23 @@ GLCanvas3DManager::GLInfo::GLInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3DManager::GLInfo::detect()
|
void GLCanvas3DManager::GLInfo::detect()
|
||||||
{
|
{
|
||||||
const char* data = (const char*)::glGetString(GL_VERSION);
|
const char* data = (const char*)::glGetString(GL_VERSION);
|
||||||
if (data == nullptr)
|
if (data != nullptr)
|
||||||
return false;
|
|
||||||
|
|
||||||
version = data;
|
version = data;
|
||||||
|
|
||||||
data = (const char*)::glGetString(GL_SHADING_LANGUAGE_VERSION);
|
data = (const char*)::glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||||
if (data == nullptr)
|
if (data != nullptr)
|
||||||
return false;
|
|
||||||
|
|
||||||
glsl_version = data;
|
glsl_version = data;
|
||||||
|
|
||||||
data = (const char*)::glGetString(GL_VENDOR);
|
data = (const char*)::glGetString(GL_VENDOR);
|
||||||
if (data == nullptr)
|
if (data != nullptr)
|
||||||
return false;
|
|
||||||
|
|
||||||
vendor = data;
|
vendor = data;
|
||||||
|
|
||||||
data = (const char*)::glGetString(GL_RENDERER);
|
data = (const char*)::glGetString(GL_RENDERER);
|
||||||
if (data == nullptr)
|
if (data != nullptr)
|
||||||
return false;
|
|
||||||
|
|
||||||
renderer = data;
|
renderer = data;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
|
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";
|
std::string line_end = format_as_html ? "<br>" : "\n";
|
||||||
|
|
||||||
out << h2_start << "OpenGL installation" << h2_end << line_end;
|
out << h2_start << "OpenGL installation" << h2_end << line_end;
|
||||||
out << b_start << "GL version: " << b_end << version << line_end;
|
out << b_start << "GL version: " << b_end << (version.empty() ? "N/A" : version) << line_end;
|
||||||
out << b_start << "Vendor: " << b_end << vendor << line_end;
|
out << b_start << "Vendor: " << b_end << (vendor.empty() ? "N/A" : vendor) << line_end;
|
||||||
out << b_start << "Renderer: " << b_end << renderer << line_end;
|
out << b_start << "Renderer: " << b_end << (renderer.empty() ? "N/A" : renderer) << line_end;
|
||||||
out << b_start << "GLSL version: " << b_end << glsl_version << line_end;
|
out << b_start << "GLSL version: " << b_end << (glsl_version.empty() ? "N/A" : glsl_version) << line_end;
|
||||||
|
|
||||||
if (extensions)
|
if (extensions)
|
||||||
{
|
{
|
||||||
|
@ -195,16 +185,12 @@ void GLCanvas3DManager::init_gl()
|
||||||
if (!m_gl_initialized)
|
if (!m_gl_initialized)
|
||||||
{
|
{
|
||||||
glewInit();
|
glewInit();
|
||||||
if (m_gl_info.detect())
|
m_gl_info.detect();
|
||||||
{
|
|
||||||
const AppConfig* config = GUI::get_app_config();
|
const AppConfig* config = GUI::get_app_config();
|
||||||
m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1");
|
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_use_VBOs = !m_use_legacy_opengl && m_gl_info.is_version_greater_or_equal_to(2, 0);
|
||||||
m_gl_initialized = true;
|
m_gl_initialized = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
throw std::runtime_error(std::string("Unable to initialize OpenGL driver\n"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GLCanvas3DManager::get_gl_info(bool format_as_html, bool extensions) const
|
std::string GLCanvas3DManager::get_gl_info(bool format_as_html, bool extensions) const
|
||||||
|
|
|
@ -35,7 +35,7 @@ class GLCanvas3DManager
|
||||||
|
|
||||||
GLInfo();
|
GLInfo();
|
||||||
|
|
||||||
bool detect();
|
void detect();
|
||||||
bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const;
|
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;
|
std::string to_string(bool format_as_html, bool extensions) const;
|
||||||
|
|
Loading…
Reference in a new issue