summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformopenglcontext.cpp
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2012-09-18 17:05:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-26 19:21:15 +0200
commitaad58ac87e371129ee61168effd9daa491b476ab (patch)
tree7dfd20e817f1003eb008b75f8d27bd9194fd76d3 /src/gui/kernel/qplatformopenglcontext.cpp
parent61d853797bff92d206db0d7fa6666c116f5ff00f (diff)
XCB: Correctly report the created OpenGL context version and profile
This commit fixes the xcb qpa plugin such that it now correctly reports the version and profile of the created OpenGL context in the QOpenGLSurfaceFormat. To do this we have to create a temporary X window so that we can make our new context current. We also handle the buggy nVidia drivers which incorrectly report 0 for the GL_CONTEXT_PROFILE_MASK query. The reduced format is also copied back from qglx_findVisualInfo. Change-Id: I6f34fe1c6130aebbb6b40c36df4acc216069d2b1 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/gui/kernel/qplatformopenglcontext.cpp')
-rw-r--r--src/gui/kernel/qplatformopenglcontext.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformopenglcontext.cpp b/src/gui/kernel/qplatformopenglcontext.cpp
index ed8ab09479..8e6a9da562 100644
--- a/src/gui/kernel/qplatformopenglcontext.cpp
+++ b/src/gui/kernel/qplatformopenglcontext.cpp
@@ -118,4 +118,38 @@ void QPlatformOpenGLContext::setContext(QOpenGLContext *context)
d->context = context;
}
+bool QPlatformOpenGLContext::parseOpenGLVersion(const QString& versionString, int &major, int &minor)
+{
+ bool majorOk = false;
+ bool minorOk = false;
+ QStringList parts = versionString.split(QLatin1Char(' '));
+ if (versionString.startsWith(QLatin1String("OpenGL ES"))) {
+ if (parts.size() >= 3) {
+ QStringList versionParts = parts.at(2).split(QLatin1Char('.'));
+ if (versionParts.size() >= 2) {
+ major = versionParts.at(0).toInt(&majorOk);
+ minor = versionParts.at(1).toInt(&minorOk);
+ } else {
+ qWarning("Unrecognized OpenGL ES version");
+ }
+ } else {
+ // If < 3 parts to the name, it is an unrecognised OpenGL ES
+ qWarning("Unrecognised OpenGL ES version");
+ }
+ } else {
+ // Not OpenGL ES, but regular OpenGL, the version numbers are first in the string
+ QStringList versionParts = parts.at(0).split(QLatin1Char('.'));
+ if (versionParts.size() >= 2) {
+ major = versionParts.at(0).toInt(&majorOk);
+ minor = versionParts.at(1).toInt(&minorOk);
+ } else {
+ qWarning("Unrecognized OpenGL version");
+ }
+ }
+
+ if (!majorOk || !minorOk)
+ qWarning("Unrecognized OpenGL version");
+ return (majorOk && minorOk);
+}
+
QT_END_NAMESPACE