<div dir="ltr"><div>I managed to create our custom renderer by sharing the OpenGL context Qt provides with qt_gl_global_share_context() and Qt::AA_ShareOpenGLContexts.<br>Using wglCreateContextAttribsARB() on our side, wharing worked without errors, and it fixed some of our visual bugs.<br></div><div>We also made sure to call wglMakeCurrent() before we draw.<br></div><div><br>however I still get glitches: QML widget drawn in a half-quad, black window, Qt window resizing our framebuffer, hover effects making our renderer flicker... etc<br></div><div><br>I tried to launch gDebugger to see what's going on, and it seems not all of Qt's contextes are shared.<br></div><div>Any idea how it can be solved?<br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-18 18:11 GMT+02:00 Marc Gilleron <span dir="ltr"><<a href="mailto:marc.gilleron@gmail.com" target="_blank">marc.gilleron@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Actually, here is what we have:<br><br>Our application has a main thread loop.<br>It loads Qt dynamically (because we don't necessarily need it at compile time). Qt doesn't wraps our app.<br>At some point in our main thread, we create a QApplication and widgets.<br>Then, as we did before Qt integration, we load our OpenGL renderer. It creates its own context, may load resources at any time, and currently draws in its own non-Qt window.<br><br>But, the simple fact we now have Qt Windows and non-Qt windows with OpenGL at the same time produces glitches in our renderer, and we're trying to solve it.<br>(We do this to keep them independant from each other. In the future we may wrap our renderer window in a QWindow but at the moment we try to make it just work).<br><br>Here is the kind of code I used to perform sharing, just after we create our custom OpenGL context:<br><br>        // Get the main Qt context<br>        Q_ASSERT(qGuiApp);<br>        QOpenGLContext * qtContext = qt_gl_global_share_context();<br>        if (qtContext == 0)<br>        {<br>            // Qt: Global OpenGL context is not available<br>            return 0;<br>        }<br>#ifdef WIN32<br>        // We get our renderer's OpenGL context<br>        HGLRC hOurContext = /* get from somewhere */<br>        HWND hOurWindow = /* get from somewhere */<br><br>        QWGLNativeContext ourNativeContext(hOurContext, hOurWindow);<br>        QOpenGLContext * ourContext = new QOpenGLContext;<br>        ourContext->setNativeHandle(QVariant::fromValue(ourNativeContext));<br>        ourContext->setShareContext(qtContext);<br>        ourContext->create();<br>#else<br><br>However I didn't noticed any difference. Or is this the wrong way to share?<br><br>Or maybe there is one more problem:<br>we are still single-threaded, so we need to make sure the current OpenGL is the good one when we perform our calls.<br>I said we cannot use the the approaches needing paintGL() and the like, because we would be outside of our main loop, and would lead to side-effects.<br><br>I also wonder if we can put the Qt main loop in ours, because at the moment we have no clue when it updates...<br><br></div>
</blockquote></div><br></div>