Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Is it impossible that 2 QQuickRenderControl use same QOpenGLContext?
QtWS25 Last Chance

Is it impossible that 2 QQuickRenderControl use same QOpenGLContext?

Scheduled Pinned Locked Moved QML and Qt Quick
openglqquickrenderconqt quick
2 Posts 2 Posters 785 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jarvishuang
    wrote on last edited by jarvishuang
    #1

    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

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nicolas Kogler
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved