summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-06-23 17:24:37 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-27 00:46:35 +0200
commit6874a33a75154400e8cd0424cec6d464b133c7cc (patch)
tree7bbc58b8a560522001a97180f03d191839d1d7b4 /src/platformsupport/eglconvenience/qeglplatformcontext.cpp
parentcd853c0ad7a74a81aa831968c7ded60874b161ae (diff)
Fixed missing way of choosing EGL renderable type with QSurfaceFormat.
This has been long overdue, since EGL now lets you choose between desktop and ES based OpenGL. We also add OpenVG for those who want to use raw OpenVG with a QOpenGLContext. The underlying EGL API for using OpenGL / OpenVG is the same, with eglMakeCurrent() and eglSwapBuffers(). Change-Id: Ib0146b3fde5fe632069ebf99e7712f496ee7ea4d Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/platformsupport/eglconvenience/qeglplatformcontext.cpp')
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
index 2e7baa0e1d..5e7a3b6ed9 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
@@ -47,6 +47,18 @@
#include <EGL/egl.h>
+static inline void bindApi(const QSurfaceFormat &format)
+{
+ if (format.renderableType() == QSurfaceFormat::OpenVG)
+ eglBindAPI(EGL_OPENVG_API);
+#ifdef EGL_VERSION_1_4
+ else if (format.renderableType() == QSurfaceFormat::OpenGL)
+ eglBindAPI(EGL_OPENGL_API);
+#endif
+ else
+ eglBindAPI(EGL_OPENGL_ES_API);
+}
+
QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
EGLenum eglApi)
: m_eglDisplay(display)
@@ -61,7 +73,7 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform
contextAttrs.append(format.majorVersion());
contextAttrs.append(EGL_NONE);
- eglBindAPI(m_eglApi);
+ bindApi(m_format);
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, m_shareContext, contextAttrs.constData());
if (m_eglContext == EGL_NO_CONTEXT && m_shareContext != EGL_NO_CONTEXT) {
m_shareContext = 0;
@@ -76,7 +88,7 @@ bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::makeCurrent: %p\n",this);
#endif
- eglBindAPI(m_eglApi);
+ bindApi(m_format);
EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);
@@ -121,7 +133,7 @@ void QEGLPlatformContext::doneCurrent()
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::doneCurrent:%p\n",this);
#endif
- eglBindAPI(m_eglApi);
+ bindApi(m_format);
bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!ok)
qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this);
@@ -132,7 +144,7 @@ void QEGLPlatformContext::swapBuffers(QPlatformSurface *surface)
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::swapBuffers:%p\n",this);
#endif
- eglBindAPI(m_eglApi);
+ bindApi(m_format);
EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);
bool ok = eglSwapBuffers(m_eglDisplay, eglSurface);
if (!ok)
@@ -144,7 +156,7 @@ void (*QEGLPlatformContext::getProcAddress(const QByteArray &procName)) ()
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::getProcAddress%p\n",this);
#endif
- eglBindAPI(m_eglApi);
+ bindApi(m_format);
return eglGetProcAddress(procName.constData());
}