[Interest] How to share a native OpenGL context with Qt?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Wed Jun 17 23:41:52 CEST 2015


Il 17/06/2015 17:54, Marc Gilleron ha scritto:
> Our context is created in a custom way, nothing to do with Qt in the
> first place.
> We made a test with a QML window and another non-Qt window where we used
> to render OpenGL, and it doesn't works because of resource clashes.
> So we need to share.
> Is there a way to do this with Qt by setting the
> |Qt::AA_ShareOpenGLContexts |flag? I didn't found any global context to
> call share on it in the public API...

I've added a getter for that global context in 5.5:

> http://doc-snapshots.qt.io/qt5-5.5/qopenglcontext.html#globalShareContext

If you peek at the implementation you can actually also grab it on <= 
5.4 by using some private APIs.

> Note: I know there are canonical ways to draw OpenGL stuff in Qt,
> however, none of them currently suits our needs in terms of existing
> codebase and time. We want to be able to draw from our own loop, in our
> own surface, which is neither inside a paintGL()/Qt call, nor in another
> thread.

Now from your email I'm not 100% sure of what you need to achieve. Do 
you want to draw QML content on top of some other OpenGL content, and do 
that in a non-Qt window / GL context? There's QQuickRenderControl for that.

Hope this helps,
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - The Qt Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4048 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150617/8f00d085/attachment.bin>

More information about the Interest mailing list