Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to get egl-related native pointers/handles from Qt App / QOpenGLContext
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 1 Posters 1.3k 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.
  • B Offline
    B Offline
    Bodo
    wrote on 14 Aug 2019, 15:09 last edited by
    #1

    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

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bodo
      wrote on 15 Aug 2019, 15:05 last edited by
      #2

      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

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bodo
        wrote on 19 Aug 2019, 07:12 last edited by
        #3

        Add 2:

        I reconfigured + make / installed Qt with -opengl es2.

        Now this:

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

        is returning some address and not NULL anymore.
        So it seems that Qt has not EGL context available when using Desktop OpenGL.

        Lets see if I can use this as current context...

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bodo
          wrote on 19 Aug 2019, 11:16 last edited by
          #4

          Add 3:

          Using the nativeHandle I have access to:
          QEGLNativeContext::display()
          and
          QEGLNativeContext::context()

          If I use these both and try a eglMakeCurrent, I get a
          EGL_BAD_MATCH

          So (from the docs) I assume something is wrong with the surface.

          At the moment I create a surface via:

          m_surface = eglCreateWindowSurface(m_display, m_config, m_window, NULL);
          

          Where m_window is grabbed by DefaultRootWindow(QX11Info::display())
          and m_config is a found config with 32bit color, 24bit depth, 0 EGL_SAMPLES and the EGL_WINDOW_BOT in EGL_SURFACE_TYPE.

          I crawled the web a about and found some hints that the surface attributes might not find.

          Is there any info on how Qt likes to have the surface? Or is there already a surface for the EGL context of the natrive handle?

          1 Reply Last reply
          0

          1/4

          14 Aug 2019, 15:09

          • Login

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