Integrating existing OpenGL renderer in Qt Quick 2



  • Hello

    I'm currently working on integrating an existing OpenGL renderer into Qt Quick. I took inspiration from https://github.com/advancingu/QmlOgre/tree/master/lib (Ogre integration) and tried to achieve something similar, but not limited to ogre.

    My current status is the following: https://gist.github.com/krond/8191037
    Short summary of the code: I tried creating a custom Qml Component that creates a shared OpenGL context with the one from Qt Quick and bind to a framebuffer that writes to a texture before calling the actual renderer.

    Unfortunately, it doesn't fully work yet. I have the following insights:

    The renderer works standalone if used with glfw or with QWindow.

    • In the display()-method of the renderer, I suffixed every OpenGL call with a glGetError() and I always get 0 (no error).
    • I checked the instantiated QOpenGL* objects (from Qt) that provide a isValid()/isBound() method and they all return true.
    • If i set a different clear color with glClearColor() in the renderers initialize()-method, the background actually gets filled with the correct color and is also displayed in the Qt Quick GUI.
    • After the glFlush() i can do a QOpenGLFramebufferObject.toImage().save() and the image is also filled with the same color, so I guess the framebuffer to texture is working.

    I'm new to Qt Quick and I don't know the things going on behind the scenes, so I have these questions:

    • Why could other OpenGL calls besides glClear() not be working?
    • Do you guys have any guesses or ideas what the problem might be or where I had some wrong thoughts?

    I'm not sure if users try out code posted in forums, but if you are interested, I put together a minimal example that shows the problem: https://dl.dropboxusercontent.com/u/44536413/Test.zip (There are two Qt project and main files: one working, the other not).
    I'm using Qt 5.2 and MSVC2012 32bit for compilation.

    Thanks and a happy new year,
    Hornet


Log in to reply
 

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