aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-02-23 13:22:13 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-25 17:08:02 +0100
commit501bd0fa6709caff3d5425abc16fa8ef3f5c88af (patch)
treef15f6b7977a0af5006348736494e2029079e9232
parentaaea23708a46259094a8203f73ee0650c362d85f (diff)
Fix crashes and incorrect extension queries on GL3+
glGetString(GL_EXTENSIONS) is deprecated in OpenGL 3.0+. This means that in core profiles on 3.2+ (or without the fwd compatibility bit on 3.0/3.1), the call is not supported and may return NULL. This causes a crash in at least one place where we try to blindly strstr the result. The correct solution is to use QOpenGLContext::extensions() and hasExtension() which is prepared to handle GL3+. Change-Id: I52fec7dcee001cdc0933af03f5eed4b7c822b2bb Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture.cpp6
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp6
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgpainternode.cpp6
4 files changed, 10 insertions, 10 deletions
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp
index d3f2a956a3..ef1b65a04f 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp
@@ -479,9 +479,9 @@ bool QQuickContext2DFBOTexture::doMultisampling() const
static bool multisamplingSupported = false;
if (!extensionsChecked) {
- QList<QByteArray> extensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' ');
- multisamplingSupported = extensions.contains("GL_EXT_framebuffer_multisample")
- && extensions.contains("GL_EXT_framebuffer_blit");
+ const QSet<QByteArray> extensions = m_context->glContext()->extensions();
+ multisamplingSupported = extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_multisample"))
+ && extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_blit"));
extensionsChecked = true;
}
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index 98203c51e5..f78a05ea9a 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -353,9 +353,9 @@ void QQuickShaderEffectTexture::grab()
if (m_context->openglContext()->format().samples() <= 1) {
m_multisampling = false;
} else {
- QList<QByteArray> extensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' ');
- m_multisampling = extensions.contains("GL_EXT_framebuffer_multisample")
- && extensions.contains("GL_EXT_framebuffer_blit");
+ const QSet<QByteArray> extensions = m_context->openglContext()->extensions();
+ m_multisampling = extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_multisample"))
+ && extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_blit"));
}
m_multisamplingChecked = true;
}
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index ad0c9dad07..3267eeed83 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -206,7 +206,7 @@ void QSG24BitTextMaskShader::initialize()
QSGTextMaskShader::initialize();
// 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0,
// but using sRGB looks okay.
- if (strstr((const char *) glGetString(GL_EXTENSIONS), "GL_ARB_framebuffer_sRGB")
+ if (QOpenGLContext::currentContext()->hasExtension(QByteArrayLiteral("GL_ARB_framebuffer_sRGB"))
&& m_glyphFormat == QFontEngine::Format_A32
&& qAbs(fontSmoothingGamma() - 2.2) < 0.25) {
m_useSRGB = true;
diff --git a/src/quick/scenegraph/util/qsgpainternode.cpp b/src/quick/scenegraph/util/qsgpainternode.cpp
index ec44a994e0..b454f666ac 100644
--- a/src/quick/scenegraph/util/qsgpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgpainternode.cpp
@@ -231,9 +231,9 @@ void QSGPainterNode::updateGeometry()
void QSGPainterNode::updateRenderTarget()
{
if (!m_extensionsChecked) {
- QList<QByteArray> extensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' ');
- m_multisamplingSupported = extensions.contains("GL_EXT_framebuffer_multisample")
- && extensions.contains("GL_EXT_framebuffer_blit");
+ const QSet<QByteArray> extensions = m_context->openglContext()->extensions();
+ m_multisamplingSupported = extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_multisample"))
+ && extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_blit"));
m_extensionsChecked = true;
}