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 <jorgen.lind@theqtcompany.com>
bb10
Laszlo Agocs 2014-12-02 16:59:53 +01:00
parent 370d421495
commit d52ea19862
1 changed files with 6 additions and 0 deletions

View File

@ -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());
context->setFormat(q->requestedFormat());
if (!context->create())
qWarning("QOpenGLWindow::beginPaint: Failed to create context");