diff options
author | Inho Lee <[email protected]> | 2024-03-07 15:00:52 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2024-03-16 10:14:52 +0000 |
commit | b9df93fbb5a9fa7d77008f7f2f8fe565bd4a449e (patch) | |
tree | 29a172cb89e0dcb6e9a7610a59d4afc8c4c1a7d7 | |
parent | 225c6d53d6103c211fa36d7c224f9af2cbb483c5 (diff) |
Fix offscreen rendering in QOpenGLWidget
Amends 68a4c5da9a080101cccd8a3b2edb1c908da0ca8e
In a case sharing QOpenGLContext,
offscreen renderings cannot get QOpenGLContext from Rhi.
Fixes: QTBUG-123005
Change-Id: I9baae5e5c77878885f73ee39df5cd39117e8f1c2
Reviewed-by: Tor Arne Vestbø <[email protected]>
Reviewed-by: Laszlo Agocs <[email protected]>
(cherry picked from commit 50c81f549030aba3c29f8cd161662b019028e91b)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
(cherry picked from commit 2bbfa7f18df6086c4090fa2f3823c929a1bf4ba5)
(cherry picked from commit 304666855b2cc568ce64732ae2462467944505cb)
-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 6c46f12782c..b7b339819ed 100644 --- a/src/openglwidgets/qopenglwidget.cpp +++ b/src/openglwidgets/qopenglwidget.cpp @@ -851,9 +851,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"); |