Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[SOLVED] Creating a QQuickView with a shared opengl context.

$
0
0
As it was. class MyView : QQuickView {   Q_OBJECT   public :     MyView(QWindow *parent = 0) : QQuickView(parent)     {       connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);         setPersistentOpenGLContext(true);       backgroundContext = new QOpenGLContext(this);       backgroundContext->setFormat(requestedFormat());       backgroundContext->create();       backgroundContext->makeCurrent(this);         static bool openGLExtensionsInitialized = false;       if (!openGLExtensionsInitialized) {         OpenGL::initialize(backgroundContext);         openGLExtensionsInitialized = true;       }         backgroundContext->doneCurrent();       }   protected slots :     onSceneGraphInitialized() {       openglContext()->blockSignals(true);       openglContext()->doneCurrent();       openglContext()->setShareContext(backgroundContext);       openglContext()->setFormat(requestedFormat());       openglContext()->create();       openglContext()->makeCurrent(this);       openglContext()->blockSignals(false);     }   protected :     QOpenGLContext *backgroundContext; };     void someInitFunction() {   MyView *view = new MyView();   view->setSource(QUrl("qrc:/script/init.qml"));   view->show();   app.exec(); }

Viewing all articles
Browse latest Browse all 4972

Trending Articles