diff options
Diffstat (limited to 'src/opengl/qglframebufferobject.cpp')
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 5585208..9674cfb 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -331,8 +331,22 @@ void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f, } } +QGLContext *QGLFBOGLPaintDevice::context() const +{ + QGLContext *fboContext = const_cast<QGLContext *>(fbo->d_ptr->fbo_guard.context()); + QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext()); + + if (QGLContextPrivate::contextGroup(fboContext) == QGLContextPrivate::contextGroup(currentContext)) + return currentContext; + else + return fboContext; +} + void QGLFBOGLPaintDevice::ensureActiveTarget() { + if (QGLContext::currentContext() != context()) + context()->makeCurrent(); + QGLContext* ctx = const_cast<QGLContext*>(QGLContext::currentContext()); Q_ASSERT(ctx); const GLuint fboId = fbo->d_func()->fbo(); @@ -344,6 +358,9 @@ void QGLFBOGLPaintDevice::ensureActiveTarget() void QGLFBOGLPaintDevice::beginPaint() { + if (QGLContext::currentContext() != context()) + context()->makeCurrent(); + // We let QFBO track the previously bound FBO rather than doing it // ourselves here. This has the advantage that begin/release & bind/end // work as expected. |