From 6874a33a75154400e8cd0424cec6d464b133c7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Sat, 23 Jun 2012 17:24:37 +0200 Subject: 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 Reviewed-by: Lars Knoll --- src/gui/kernel/qsurfaceformat.cpp | 26 ++++++++++++++++++++++++++ src/gui/kernel/qsurfaceformat.h | 10 ++++++++++ 2 files changed, 36 insertions(+) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index cc6b621047..ecfeb80149 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -68,6 +68,7 @@ public: , stencilSize(-1) , swapBehavior(QSurfaceFormat::DefaultSwapBehavior) , numSamples(-1) + , renderableType(QSurfaceFormat::DefaultRenderableType) , profile(QSurfaceFormat::NoProfile) , major(2) , minor(0) @@ -85,6 +86,7 @@ public: stencilSize(other->stencilSize), swapBehavior(other->swapBehavior), numSamples(other->numSamples), + renderableType(other->renderableType), profile(other->profile), major(other->major), minor(other->minor) @@ -101,6 +103,7 @@ public: int stencilSize; QSurfaceFormat::SwapBehavior swapBehavior; int numSamples; + QSurfaceFormat::RenderableType renderableType; QSurfaceFormat::OpenGLContextProfile profile; int major; int minor; @@ -478,6 +481,29 @@ void QSurfaceFormat::setAlphaBufferSize(int size) } } +/*! + Sets the desired renderable type. + + Chooses between desktop OpenGL, OpenGL ES, and OpenVG. +*/ +void QSurfaceFormat::setRenderableType(RenderableType type) +{ + if (d->renderableType != type) { + detach(); + d->renderableType = type; + } +} + +/*! + Gets the renderable type. + + Chooses between desktop OpenGL, OpenGL ES, and OpenVG. +*/ +QSurfaceFormat::RenderableType QSurfaceFormat::renderableType() const +{ + return d->renderableType; +} + /*! Sets the desired OpenGL context profile. diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h index a4224bbedd..e8972aa8ca 100644 --- a/src/gui/kernel/qsurfaceformat.h +++ b/src/gui/kernel/qsurfaceformat.h @@ -68,6 +68,13 @@ public: TripleBuffer }; + enum RenderableType { + DefaultRenderableType = 0x0, + OpenGL = 0x1, + OpenGLES = 0x2, + OpenVG = 0x4 + }; + enum OpenGLContextProfile { NoProfile, CoreProfile, @@ -106,6 +113,9 @@ public: void setProfile(OpenGLContextProfile profile); OpenGLContextProfile profile() const; + void setRenderableType(RenderableType type); + RenderableType renderableType() const; + void setMajorVersion(int majorVersion); int majorVersion() const; -- cgit v1.2.3