diff options
author | Inho Lee <inho.lee@qt.io> | 2024-03-07 15:00:52 +0100 |
---|---|---|
committer | Inho Lee <inho.lee@qt.io> | 2024-03-07 16:10:02 +0100 |
commit | 50c81f549030aba3c29f8cd161662b019028e91b (patch) | |
tree | 45110565602deff2f9ece242d9f1c80a63e06d71 /src/openglwidgets/qopenglwidget.cpp | |
parent | f9136fd0dbdbc4f5d61b50b7fcffece6faa2ac4a (diff) |
Fix offscreen rendering in QOpenGLWidget
Amends 68a4c5da9a080101cccd8a3b2edb1c908da0ca8e
In a case sharing QOpenGLContext,
offscreen renderings cannot get QOpenGLContext from Rhi.
Fixes: QTBUG-123005
Pick-to: 6.7 6.6 6.5
Change-Id: I9baae5e5c77878885f73ee39df5cd39117e8f1c2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/openglwidgets/qopenglwidget.cpp')
-rw-r--r-- | src/openglwidgets/qopenglwidget.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/openglwidgets/qopenglwidget.cpp b/src/openglwidgets/qopenglwidget.cpp index a7b760c379..4a0bf7f492 100644 --- a/src/openglwidgets/qopenglwidget.cpp +++ b/src/openglwidgets/qopenglwidget.cpp @@ -855,9 +855,11 @@ void QOpenGLWidgetPrivate::initialize() context = new QOpenGLContext; context->setFormat(requestedFormat); - if (contextFromRhi) { - context->setShareContext(contextFromRhi); - context->setScreen(contextFromRhi->screen()); + + QOpenGLContext *shareContext = contextFromRhi ? contextFromRhi : qt_gl_global_share_context(); + if (shareContext) { + context->setShareContext(shareContext); + context->setScreen(shareContext->screen()); } if (Q_UNLIKELY(!context->create())) { qWarning("QOpenGLWidget: Failed to create context"); |