Is it impossible that 2 QQuickRenderControl use same QOpenGLContext?



  • Hi all,

    I just follow the QQuickRenderControl example to render qml to FBO. I add another QQuickRenderControl in the code (which use the same QOpenGLContext as original one), but it crashed when initialize() of the 2nd QQuickRenderControl was called:
    ASSERT: "!context->property(QSG_RENDERCONTEXT_PROPERTY).isValid()" in file scenegraph\qsgcontext.cpp, line 648

    After some search on web, I found the code in qsgcontext.cpp:

    if (m_attachToGLContext) {
    Q_ASSERT(!context->property(QSG_RENDERCONTEXT_PROPERTY).isValid());
    context->setProperty(QSG_RENDERCONTEXT_PROPERTY, QVariant::fromValue(this));
    }

    So is it impossible that 2 QQuickRenderControl use same QOpenGLContext?
    Any ideas?

    Regards,
    Jarvis



  • Sorry for putting this up again, but I faced the same issue when I tried to get 2 QQuickRenderControls render into a frame buffer of the same context. Context sharing was no option, since it isn't support on all platforms, plus I would have had to change a good bunch of code to get it actually working with shared contexts.

    Before initializing your QQuickRenderControl, issue the following call:

    my_context->setProperty("_q_sgrendercontext", QVariant());
    

    If this property is not an invalid QVariant, the code will assert at the position the thread creator mentioned. I didn't understand the use of this magic property when looking through the sources yet, but it seems that this property isn't used elsewhere and kind of redundant.

    Sometimes it seems like the Qt developers like to give us riddles like that lol :-D.


Log in to reply
 

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