From b3fed1c9b2a1720ab33afbb6ba44b5eadc39e25a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Thu, 17 Nov 2016 07:21:18 +0200 Subject: Check if we got OpenGL2.1 functions before trying to use them Change-Id: Ia8b4a25094d4a608d3a20b808fd14c3941ae2dff Task-number: QTRD-2116 Reviewed-by: Miikka Heikkinen --- src/datavisualization/engine/abstract3drenderer.cpp | 6 +++++- src/datavisualization/utils/texturehelper.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp index ecef2598..4a681554 100644 --- a/src/datavisualization/engine/abstract3drenderer.cpp +++ b/src/datavisualization/engine/abstract3drenderer.cpp @@ -134,10 +134,14 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller) QtMessageHandler handler = qInstallMessageHandler(discardDebugMsgs); m_funcs_2_1 = QOpenGLContext::currentContext()->versionFunctions(); - 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); diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp index 7a5098c4..fb7b099a 100644 --- a/src/datavisualization/utils/texturehelper.cpp +++ b/src/datavisualization/utils/texturehelper.cpp @@ -49,10 +49,14 @@ TextureHelper::TextureHelper() m_openGlFunctions_2_1 = QOpenGLContext::currentContext()->versionFunctions(); - 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 } -- cgit v1.2.3