I can't get Qml to play nicely with my OpenGL!

  • I have a complicated OpenGL setup that I would like to display in a specific section of the view where (1) the rest of the view has other Qml items on it (including a nice gradient background under the entire view) and (2) I can draw some additional text (Qml Labels) on top of my OpenGL.

    As a learning experience, I've got the Bezier Curve example (http://qt-project.org/doc/qt-5/qtquick-scenegraph-customgeometry-example.html) working, but my OpenGL doesn't fit into the nodes that Qml provides, so I don't think that's the way to go.

    I considered taking my OpenGL and converting it into an image which I send to Qml via a QQuickImageProvider, but efficiency is going to be really important and that seems like a lot of extra CPU work - especially since my OpenGL view will be in the GPU already, copying the image into CPU and then back to GPU can't be good.

    So that seems to leave the QQuickWindow calls (beforeRendering(), etc.) and I have the Squircle example working (http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html) but I can't get the z-order working for me.

    If I draw my OpenGL during QQuickWindow::beforeRendering(), the nice gradient background overwrites it completely. If I draw my OpenGL during QQuickWindow::afterRendering(), any Qml Labels end up underneath my OpenGL instead of on top of it (right?).

    So you can see I'm confused and not sure which path to take.

    What is the recommended/best way to display complex OpenGL inside a Qml view?


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.