Check if we got OpenGL2.1 functions before trying to use them

Change-Id: Ia8b4a25094d4a608d3a20b808fd14c3941ae2dff
Task-number: QTRD-2116
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Tomi Korpipää 2016-11-17 07:21:18 +02:00
parent 0d4096ab9d
commit b3fed1c9b2
2 changed files with 10 additions and 2 deletions

View File

@ -134,10 +134,14 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
QtMessageHandler handler = qInstallMessageHandler(discardDebugMsgs);
m_funcs_2_1 = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>();
m_funcs_2_1->initializeOpenGLFunctions();
if (m_funcs_2_1)
m_funcs_2_1->initializeOpenGLFunctions();
// Restore original message handler
qInstallMessageHandler(handler);
if (!m_funcs_2_1)
qFatal("OpenGL version is too low, at least 2.1 is required");
}
#endif
QObject::connect(m_drawer, &Drawer::drawerChanged, this, &Abstract3DRenderer::updateTextures);

View File

@ -49,10 +49,14 @@ TextureHelper::TextureHelper()
m_openGlFunctions_2_1 =
QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>();
m_openGlFunctions_2_1->initializeOpenGLFunctions();
if (m_openGlFunctions_2_1)
m_openGlFunctions_2_1->initializeOpenGLFunctions();
// Restore original message handler
qInstallMessageHandler(handler);
if (!m_openGlFunctions_2_1)
qFatal("OpenGL version is too low, at least 2.1 is required");
}
#endif
}