How to get egl-related native pointers/handles from Qt App / QOpenGLContext



  • Hi,

    I'm (desperately) trying to display an EGL stream within a qml object.

    While investigating I read somewhere that one should use the Qt EGL objects in order to use the underlying EGL that Qt is using.

    But the problem is kind of specific and the documentation is thin on this.

    Basically the purely egl-based setup is working until I want to make the context current. Then I'm getting an EGL_BAD_ACCESS. So I'm assuming another context / thread here as I'm pretty sure that I'm on the right / intended thread.

    There are a lot of options that may be a problem too.

    So lets start at my Qt config:

    ./configure -prefix /opt/Qt5.13 -opensource -confirm-license -xcb-xlib -qt-xcb -nomake examples -nomake tests
    

    The output (stripped) of the configure is:

    Qt Gui:
      EGL .................................... yes
      OpenGL:
        Desktop OpenGL ....................... yes
        OpenGL ES 2.0 ........................ no
        OpenGL ES 3.0 ........................ no
        OpenGL ES 3.1 ........................ no
        OpenGL ES 3.2 ........................ no
    Features used by QPA backends:
      xkbcommon .............................. yes
      X11 specific:
        XLib ................................. yes
        XCB Xlib ............................. yes
        EGL on X11 ........................... yes
    QPA backends:
      EGLFS .................................. yes
      EGLFS details:
        EGLFS EGLDevice ...................... yes
        EGLFS X11 ............................ yes
      XCB:
        Using system-provided XCB libraries .. no
        XCB XKB .............................. yes
        XCB XInput ........................... yes
        Native painting (experimental) ....... yes
        GL integrations:
          GLX Plugin ......................... yes
            XCB GLX .......................... yes
          EGL-X11 Plugin ..................... yes
    
    

    So this looks fine. From what I can see I should be able to use Desktop OpenGL with underlying EGL.
    I want to avoid EGLFS as this is limited to be fullscreen only (according to the docs). But I'm targeting an output with different EGL sources rendererd to different qml items (imagine like a screen wall with different streams and overlaying Qt UI).

    At the moment I'm experimenting with QOpenGLContext to stay withing the Qt Classes, but without a success.

    I also tried:

      m_qOpenGLContext = QOpenGLContext::currentContext();
      QEGLNativeContext qEglContext = qvariant_cast<QEGLNativeContext>(m_qOpenGLContext->nativeHandle());
    

    But this is returning NULL for qEglContext...

    So I'm getting the feeling that I following the wrong assumptions / approach here.

    Maybe someone has some insights here if the basic setup is ok or if there is some fundamental problem...

    Thanks,
    Bodo



  • Add:

    I stumbled upon this question on another site:
    https://github.com/nigels-com/glew/issues/164

    This code is running fine and answers one of my questions if it is generally possible to use Desktop OpenGL and EGL.
    I modified the code a bit and loaded an egl extension (as I intend to use EGL streams) and got some valid proc adresses.

    So for now the big questions are:

    • Is there an existing EGL inside Qt?
      • If yes -> how can I access it?
      • If no -> how can I marry my EGL context with the OpenGL (not sure if this is possible) or how can I tell Qt to use an EGL context under the hood?

    Thanks,
    Bodo


Log in to reply
 

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