aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-05-07 19:09:39 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-05-12 08:59:08 +0000
commit66be8fcc05f0e51f12c215af3d5ab74d729386ba (patch)
treefb304a288eaac9caec229e8c32f4fa5c2dac0ead /src/quickwidgets
parentd76921e3082cd311207cd4c822ef2d357519b12f (diff)
Create contexts and pbuffers with the correct screen in QQuickWidget
Change-Id: I8e9db998eee0af5f62c1384f2dcb2028254cc642 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quickwidgets')
-rw-r--r--src/quickwidgets/qquickwidget.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 38dde806ed..f0a2a3183b 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -691,8 +691,10 @@ void QQuickWidgetPrivate::createContext()
context = new QOpenGLContext;
context->setFormat(offscreenWindow->requestedFormat());
- if (qt_gl_global_share_context())
+ if (qt_gl_global_share_context()) {
context->setShareContext(qt_gl_global_share_context());
+ context->setScreen(context->shareContext()->screen());
+ }
if (!context->create()) {
const bool isEs = context->isOpenGLES();
@@ -707,6 +709,7 @@ void QQuickWidgetPrivate::createContext()
// contains a QSurfaceFormat representing the _actual_ format of the underlying
// configuration. This is essential to get a surface that is compatible with the context.
offscreenSurface->setFormat(context->format());
+ offscreenSurface->setScreen(context->screen());
offscreenSurface->create();
}
@@ -742,7 +745,14 @@ void QQuickWidget::createFramebufferObject()
if (context->shareContext() != QWidgetPrivate::get(window())->shareContext()) {
context->setShareContext(QWidgetPrivate::get(window())->shareContext());
- context->create();
+ context->setScreen(context->shareContext()->screen());
+ if (!context->create())
+ qWarning("QQuickWidget: Failed to recreate context");
+ // The screen may be different so we must recreate the offscreen surface too.
+ // Unlike QOpenGLContext, QOffscreenSurface's create() does not recreate so have to destroy() first.
+ d->offscreenSurface->destroy();
+ d->offscreenSurface->setScreen(context->screen());
+ d->offscreenSurface->create();
}
context->makeCurrent(d->offscreenSurface);