From 2266f519225eebca724dd658d185f96bc9ad086c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 23 Mar 2015 16:18:19 +0100 Subject: Fix incorrect FBO bindings with QOpenGLWidget QOpenGLContext::defaultFramebufferObject() knows nothing about QOpenGLWidget and QQuickWidget. The problem is that this function (and others that rely on it) is expected to give the widget's backing FBO in paintGL() and friends. To overcome this, we have to provide a way for such widgets that indicate what is the expected "default fbo". Task-number: QTBUG-43269 Change-Id: I43f439f8609382b9f7004707ab0ef9f091952b4f Reviewed-by: Giuseppe D'Angelo Reviewed-by: Gunnar Sletta --- src/widgets/kernel/qopenglwidget.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index c6c5e5bc80..d4d23604a3 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -792,11 +793,18 @@ void QOpenGLWidgetPrivate::resolveSamples() void QOpenGLWidgetPrivate::invokeUserPaint() { Q_Q(QOpenGLWidget); - QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + Q_ASSERT(ctx && fbo); + + QOpenGLFunctions *f = ctx->functions(); + QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle(); f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio()); q->paintGL(); flushPending = true; + + QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0; } void QOpenGLWidgetPrivate::render() -- cgit v1.2.3