summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/eglconvenience/qeglconvenience.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/qeglconvenience.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/qeglconvenience.cpp')
-rw-r--r--src/platformsupport/eglconvenience/qeglconvenience.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp
index 8cfa8cf4c4..ca7a837fc3 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
+++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
@@ -218,7 +218,17 @@ EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format,
configureAttributes.append(surfaceType);
configureAttributes.append(EGL_RENDERABLE_TYPE);
- configureAttributes.append(format.majorVersion() == 1 ? EGL_OPENGL_ES_BIT : EGL_OPENGL_ES2_BIT);
+ if (format.renderableType() == QSurfaceFormat::OpenVG)
+ configureAttributes.append(EGL_OPENVG_BIT);
+#ifdef EGL_VERSION_1_4
+ else if (format.renderableType() == QSurfaceFormat::OpenGL)
+ configureAttributes.append(EGL_OPENGL_BIT);
+#endif
+ else if (format.majorVersion() == 1)
+ configureAttributes.append(EGL_OPENGL_ES_BIT);
+ else
+ configureAttributes.append(EGL_OPENGL_ES2_BIT);
+
configureAttributes.append(EGL_NONE);
do {
@@ -271,7 +281,7 @@ EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format,
return 0;
}
-QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config)
+QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
{
QSurfaceFormat format;
EGLint redSize = 0;
@@ -281,6 +291,7 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config)
EGLint depthSize = 0;
EGLint stencilSize = 0;
EGLint sampleCount = 0;
+ EGLint renderableType = 0;
eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
@@ -289,6 +300,16 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config)
eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
+ eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType);
+
+ if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT))
+ format.setRenderableType(QSurfaceFormat::OpenVG);
+#ifdef EGL_VERSION_1_4
+ else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL && (renderableType & EGL_OPENGL_BIT))
+ format.setRenderableType(QSurfaceFormat::OpenGL);
+#endif
+ else
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setRedBufferSize(redSize);
format.setGreenBufferSize(greenSize);