diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-03-26 16:54:36 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-01 15:51:33 +0200 |
commit | b4128d0f7dfe6fd5752c4ec3ecb03775ffda5949 (patch) | |
tree | 8c06e5551663f2418a599f02dc43c9dea156f48f /src | |
parent | 30db2159aa54aff0c28054739e2204966c584d8c (diff) |
Use an offscreen surface in VAO cleanup
Avoid failing the makeCurrent() on iOS that does not currently support
using a window with different contexts.
Change-Id: I2e10ad7e382161625a78518d02ad94edaff591ca
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 22ca35a8c3..9dfd5b2a6f 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -44,6 +44,7 @@ #include <QtCore/private/qobject_p.h> #include <QtGui/qopenglcontext.h> #include <QtGui/qopenglfunctions.h> +#include <QtGui/qoffscreensurface.h> #include <QtGui/qopenglfunctions_3_0.h> #include <QtGui/qopenglfunctions_3_2_core.h> @@ -359,9 +360,17 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() Q_D(QOpenGLVertexArrayObject); QOpenGLContext *oldContext = 0; + QScopedPointer<QOffscreenSurface> offscreenSurface; if (d->context && ctx && d->context != ctx) { oldContext = ctx; - if (d->context->makeCurrent(oldContext->surface())) { + // Cannot just make the current surface current again with another context. + // The format may be incompatible and some platforms (iOS) may impose + // restrictions on using a window with different contexts. Create an + // offscreen surface (a pbuffer or a hidden window) instead to be safe. + offscreenSurface.reset(new QOffscreenSurface); + offscreenSurface->setFormat(d->context->format()); + offscreenSurface->create(); + if (d->context->makeCurrent(offscreenSurface.data())) { ctx = d->context; } else { qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to make VAO's context current"); |