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. [SOLVED] Order of execution of QOffscreenSurface and QOpenGLContex.
QtWS25 Last Chance

[SOLVED] Order of execution of QOffscreenSurface and QOpenGLContex.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.7k 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.
  • K Offline
    K Offline
    Kiichiro
    wrote on last edited by
    #1

    I want to draw a image in the QOpenGLFramebufferObject and I use QOffscreenSurface for rendering in another thread without creating a QWindow.

    I wrote this part of code for initialize OpenGL context and on Windows all works fine.
    @
    m_surface.create();
    m_context = new QOpenGLContext(this);
    m_context->setFormat(m_surface.requestedFormat());
    m_context->create();
    m_context->makeCurrent(&m_surface);
    @

    But on my work Linux PC I have segfault in 2-nd row. And if I swap first two rows and run on Linux all works fine again.

    And question is "Why?". It's a bug or maybe I doing something wrong? I didn't find any information about order of execution for surface and context in the documentation.

    PS I don't run swapped version on Windows. And don't know whether it work.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agocs
      wrote on last edited by
      #2

      Not sure about the crash, but be aware that creating (as in create()) a QOffscreenSurface outside the gui thread is wrong, at least on Windows. This is because on Windows the QOffscreenSuface is nothing but a hidden QWindow and a regular window surface. Creating QWindows outside the gui thread will lead to issues sooner or later so it must be avoided. In fact Qt 5.2.1 and newer will show a warning in this case. On Linux there is no such limitation, though, since there QOffscreenSurface is backed by a GLX or EGL pbuffer surface.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kiichiro
        wrote on last edited by
        #3

        Do you mean that I should run create() from the gui thread and then I can create context object without issues?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          agocs
          wrote on last edited by
          #4

          Well, like I said I cannot be sure what causes the crash. But in any case, yes, call m_surface.create() on the gui thread instead.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kiichiro
            wrote on last edited by
            #5

            Ok. Thanks.

            I'd like add that to call create() need after the a.exec() was called.

            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