#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)
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;
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::makeCurrent: %p\n",this);
#endif
- eglBindAPI(m_eglApi);
+ bindApi(m_format);
EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);
#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);
#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)
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::getProcAddress%p\n",this);
#endif
- eglBindAPI(m_eglApi);
+ bindApi(m_format);
return eglGetProcAddress(procName.constData());
}