path: root/src/gui/kernel/qopenglwindow.cpp
diff options
authorLaszlo Agocs <>2014-12-02 16:59:53 +0100
committerLaszlo Agocs <>2014-12-08 10:28:13 +0100
commitd52ea19862461c7f6f49f8233594d83e1c00cde8 (patch)
tree6ac1d497a0971bad31fc7074eb6874ef23933019 /src/gui/kernel/qopenglwindow.cpp
parent370d421495a200860c9fb583b526dcf8bf8145fb (diff)
Take ShareOpenGLContexts into account in QOpenGLWindow
While the attribute was originally intended for widgets (QOpenGLWidget, QQuickWidget) only, we need a way to get multiple QOpenGLWindow instances whose contexts share with each other. Change-Id: Ib983c9c2815b0a3911bc504ffad8d8dddad192aa Reviewed-by: Jørgen Lind <>
Diffstat (limited to 'src/gui/kernel/qopenglwindow.cpp')
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp
index 158fb248dc..c37974c429 100644
--- a/src/gui/kernel/qopenglwindow.cpp
+++ b/src/gui/kernel/qopenglwindow.cpp
@@ -38,6 +38,7 @@
#include <QtGui/QOpenGLFunctions>
#include <QtGui/private/qopengltextureblitter_p.h>
#include <QtGui/private/qopenglextensions_p.h>
+#include <QtGui/private/qopenglcontext_p.h>
#include <QtGui/QMatrix4x4>
#include <QtGui/QOffscreenSurface>
@@ -101,6 +102,10 @@ QT_BEGIN_NAMESPACE
this way they do not have to redraw the entire window content on each
paintGL() call.
+ Similarly to QOpenGLWidget, QOpenGLWindow supports the Qt::AA_ShareOpenGLContexts
+ attribute. When enabled, the OpenGL contexts of all QOpenGLWindow instances will share
+ with each other. This allows accessing each other's shareable OpenGL resources.
For more information on graphics in Qt, see \l {Graphics}.
@@ -196,6 +201,7 @@ public:
if (!context) {
context.reset(new QOpenGLContext);
+ context->setShareContext(qt_gl_global_share_context());
if (!context->create())
qWarning("QOpenGLWindow::beginPaint: Failed to create context");