Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QQuickView Scene Graph's OpenGLContext is NULL
Qt 6.11 is out! See what's new in the release blog

QQuickView Scene Graph's OpenGLContext is NULL

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.8k 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.
  • lilyofvalleyL Offline
    lilyofvalleyL Offline
    lilyofvalley
    wrote on last edited by p3c0
    #1
    QSurfaceFormat format = QSurfaceFormat::defaultFormat();
    format.setVersion(4, 3);
    format.setProfile(QSurfaceFormat::CompatibilityProfile);
    QSurfaceFormat::setDefaultFormat(format);
    
    QQuickView *qview = new QQuickView();
    qview.setFormat(format);
    qview.show();
    

    After the .show(), the scene graph is initialized ( confirmed by checking QQuickWindow::isSceneGraphInitialized() ), but the QOpenGLContext::currentContext() is still NULL.
    I also try to connect a SLOT function with SIGNAL QQuickWindow::beforeRendering (as stated in http://doc.qt.io/qt-5/qquickwindow.html), with Qt::DirectConnect. But the SLOT function is not trigged after qview.show().

    How to enable the openglcontext in the QQuickView?
    Thanks!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Maybe it solve the pointer if calling QOpenGLContext::makeCurrent()

      1 Reply Last reply
      0
      • lilyofvalleyL Offline
        lilyofvalleyL Offline
        lilyofvalley
        wrote on last edited by lilyofvalley
        #3

        If calling QOpenGLContext::makeCurrent(), I get the Error: a nonstatic member reference must be relative to a specific object.

        if I called resetOpenGLState(), I get Error Info:
        QOpenGLFramebufferObject::bindDefault() called without current context

        I used a renderer from QQuickFramebufferObject::createRenderer() in QQuickView. According to the Qt Document, they share the opengl context. But in QQuickView, the opengl context is NULL.

        1 Reply Last reply
        0
        • lilyofvalleyL Offline
          lilyofvalleyL Offline
          lilyofvalley
          wrote on last edited by
          #4

          I temporarily solve the problem by using the shared context.
          Before initiate QApplication (QApplication app(argc, argv);), set the attribute to use globalshareContext:
          QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
          I get the QOpenGLContext::currentContext() in function QQuickFramebufferObject::createRenderer(), set it to be a globalshareContext, then create an OpenGL Context "QOpenGLContext *m_context = new QOpenGLContext" in QQuickView. After initialize the renderer from QQuickFramebufferObject, set it to share this globalshareContext.

          But I think a good solution is still find out the default OpenGL Context in QQuickView' Scene Graph. Qt shares this context with the renderer from QQuickFramebufferObject (according to Qt Document). Hope I can find this solution later.

          Thanks.

          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