diff options
author | Inho Lee <inho.lee@qt.io> | 2024-03-07 15:00:52 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-03-16 07:01:52 +0000 |
commit | 304666855b2cc568ce64732ae2462467944505cb (patch) | |
tree | c57f5c63382bc5f562d5f4f581930d044c764263 | |
parent | 46bbff52aa41f966dc5e750f6e9768cbde4b1223 (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.5
Change-Id: I9baae5e5c77878885f73ee39df5cd39117e8f1c2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 50c81f549030aba3c29f8cd161662b019028e91b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 2bbfa7f18df6086c4090fa2f3823c929a1bf4ba5)
-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 c1640164e6..fa93e840fc 100644 --- a/src/openglwidgets/qopenglwidget.cpp +++ b/src/openglwidgets/qopenglwidget.cpp @@ -850,9 +850,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"); |