summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-03-07 13:37:58 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-10 21:04:28 +0100
commita4f421d4311e5c0d3ebf9154856d5ecb56af292e (patch)
treec695e344097d46156820545663814d7b439c1f7b /src/platformsupport
parent5aaec4800066801f069dfb4606c5d9551a9b8110 (diff)
egl: Update the OpenGL version in the context's QSurfaceFormat
The GLX and WGL support code does this already. Do it for EGL too since requesting OpenGLES with majorVersion 3 results in GLES3 (where supported) and in this case the expected majorVersion in QOpenGLContext::format() is 3. Change-Id: I73d61d7569e6ebaa91aef57fb1b0051a77a73355 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
index e1c53196e6..ace83289c9 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
@@ -41,6 +41,7 @@
#include "qeglplatformcontext_p.h"
#include "qeglconvenience_p.h"
+#include "qeglpbuffer_p.h"
#include <qpa/qplatformwindow.h>
#include <QOpenGLContext>
@@ -126,6 +127,36 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont
m_shareContext = 0;
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, 0, contextAttrs.constData());
}
+
+ if (m_eglContext == EGL_NO_CONTEXT) {
+ qWarning("QEGLPlatformContext::init: eglError: %x, this: %p \n", eglGetError(), this);
+ return;
+ }
+
+ // Make the context current to ensure the GL version query works. This needs a surface too.
+ const EGLint pbufferAttributes[] = {
+ EGL_WIDTH, 1,
+ EGL_HEIGHT, 1,
+ EGL_LARGEST_PBUFFER, EGL_FALSE,
+ EGL_NONE
+ };
+ EGLSurface pbuffer = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, pbufferAttributes);
+ if (pbuffer == EGL_NO_SURFACE)
+ return;
+
+ if (eglMakeCurrent(m_eglDisplay, pbuffer, pbuffer, m_eglContext)) {
+ const GLubyte *s = glGetString(GL_VERSION);
+ if (s) {
+ QByteArray version = QByteArray(reinterpret_cast<const char *>(s));
+ int major, minor;
+ if (QPlatformOpenGLContext::parseOpenGLVersion(version, major, minor)) {
+ m_format.setMajorVersion(major);
+ m_format.setMinorVersion(minor);
+ }
+ }
+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ }
+ eglDestroySurface(m_eglDisplay, pbuffer);
}
bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)