Interacting QML with external C++ OpenGL library



  • Hello,

    I am in the process of building a desktop OpenGL 3.3 app that would use QT5 QML for the UI parts and an external C++ standalone application (Core Renderer) for rendering the OpenGL scene.

    The separation would be thus:

    QT QML User Interface <----> Core Renderer

    I want to keep the Core Renderer separate, as it would be used in other projects also.
    The QML UI would control the Core Renderer through a public API exposed in the Core Renderer header files. For example modify objects, set object properties and so on that are rendered.

    What would be a good approach to integrate this Core Renderer into a QT5 Project ?
    If possible, I don't want to make the Core Renderer part dependent of the QT libraries.

    I have been looking into this, and currently the viable solution would look like this:

    • Specify the public API in the Core Renderer Header files
    • Include the Core Renderer in the QT5 UI application as a static library
    • Build a QML -> Core Renderer Bridge in the QT5 project, so that QML can call some sort of C++ wrapper that then calls the actual Core Renderer external methods, so we don't have any dependencies to QT in the Core Renderer part.

    Is this possible ? Any examples doing this already ?

    Idea would be to create the OpenGL Context in QT and then pass that created to the Core Renderer that would then handle the rendering from there. Is this possible ?

    Thank you for any help!


  • Moderators

    I'm not that intimate with internals of the QML engine (this is rather a question for Gunnar or Alan, you can catch them on IRC or the Interest mailing list), but I think the easiest way would be this:

    make your Core Renderer do it's job, then put out a texture that you - on the Qt and QML side - will intercept and put onto a customized QQuickItem, which will in turn paint it. This means you have a completely separate Core Renderer, as you want. And for Qt, you only add one QQuickItem, which you can use in whatever way you want, and interact with it the same way you can interact with any other item.



  • Thank you for the answer sierdzio :) I will look at that method and see if it works. Sounds like it should be relatively easy to implement.


Log in to reply
 

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