From 2f96fb1beec5251e27381c09d0ad810c6e829c37 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 9 Sep 2014 10:06:45 +0200 Subject: Add an option to share between TLWs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-41191 Change-Id: I510d1631926ed0d9e371703d22229aed92432aa6 Reviewed-by: Jørgen Lind --- src/widgets/kernel/qopenglwidget.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/widgets/kernel/qopenglwidget.cpp') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 3dae22cdc7..8f7751618d 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -297,6 +297,18 @@ QT_BEGIN_NAMESPACE sharable resources, like textures, and there is no need for an extra "global share" context, as was the case with QGLWidget. + To set up sharing between QOpenGLWidget instances belonging to different + windows, set the Qt::AA_ShareOpenGLContexts application attribute before + instantiating QApplication. This will trigger sharing between all + QOpenGLWidget instances without any further steps. + + Creating extra QOpenGLContext instances that share resources like textures + with the QOpenGLWidget's context is also possible. Simply pass the pointer + returned from context() to QOpenGLContext::setShareContext() before calling + QOpenGLContext::create(). The resulting context can also be used on a + different thread, allowing threaded generation of textures and asynchronous + texture uploads. + Note that QOpenGLWidget expects a standard conformant implementation of resource sharing when it comes to the underlying graphics drivers. For example, some drivers, in particular for mobile and embedded hardware, have @@ -359,11 +371,12 @@ QT_BEGIN_NAMESPACE each QOpenGLWidget's associated context is destroyed together with the QOpenGLWidget, the sharable resources in that context, like textures, will stay valid until the top-level window, in which the QOpenGLWidget lived, is - destroyed. Additionally, some Qt modules may trigger an even wider scope for - sharing contexts, potentially leading to keeping the resources in question - alive for the entire lifetime of the application. Therefore the safest and - most robust is always to perform explicit cleanup for all resources and - resource wrappers used in the QOpenGLWidget. + destroyed. Additionally, settings like Qt::AA_ShareOpenGLContexts and some Qt + modules may trigger an even wider scope for sharing contexts, potentially + leading to keeping the resources in question alive for the entire lifetime of + the application. Therefore the safest and most robust is always to perform + explicit cleanup for all resources and resource wrappers used in the + QOpenGLWidget. \section1 Limitations @@ -388,7 +401,7 @@ QT_BEGIN_NAMESPACE \e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.} - \sa QOpenGLFunctions, QOpenGLWindow + \sa QOpenGLFunctions, QOpenGLWindow, Qt::AA_ShareOpenGLContexts */ /*! -- cgit v1.2.3