summaryrefslogtreecommitdiffstats
path: root/src/opengl/qglframebufferobject.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-10-12 13:48:50 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-10-12 15:11:37 (GMT)
commite5954bba5bb1f88a847570d4790d0cef64f92209 (patch)
treecadbd97053d151db48fd61ac182a73106cb5909f /src/opengl/qglframebufferobject.cpp
parent96bf551ec168e9b0d1a7c0892c4f809149c6ec51 (diff)
downloadQt-e5954bba5bb1f88a847570d4790d0cef64f92209.zip
Qt-e5954bba5bb1f88a847570d4790d0cef64f92209.tar.gz
Qt-e5954bba5bb1f88a847570d4790d0cef64f92209.tar.bz2
Fixed bug when using QGLWidgets in -graphicssystem opengl
We need to make sure that the FBO is bound in a valid context. Reviewed-by: Tom
Diffstat (limited to 'src/opengl/qglframebufferobject.cpp')
-rw-r--r--src/opengl/qglframebufferobject.cpp17
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.