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] hellogl and threaded rendering: cannot get it to work
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] hellogl and threaded rendering: cannot get it to work

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k Views 1 Watching
  • 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.
  • F Offline
    F Offline
    floatingWoods
    wrote on 23 Sept 2013, 08:12 last edited by
    #1

    Hello,
    I would like to make the demo application hellogl use a thread for rendering (different thread than the main or GUI thread). I slightly modified the hellogl app by:

    • starting a new thread in the initializeGL() function
    • the new thread will then call the original initializeGL() function
    • the new thread will then call on a regular basis the original painGL() function

    The result: a black window. I then figured out that I need to call makeCurrent() from the thread. This crashes the application with the message: Cannot make QOpenGLContext current in a different thread

    From the main thread, I then I tried to move the QOGLContext to the new thread (before starting the new thread with start()) with context()->moveToThread(newThread) It then tells me again: Cannot make QOpenGLContext current in a different thread

    What am I doing wrong?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Sept 2013, 09:11 last edited by
      #2

      Hi,

      You might be interested by "this article":http://blog.qt.digia.com/blog/2011/06/03/threaded-opengl-in-4-8/ to get you started

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        floatingWoods
        wrote on 23 Sept 2013, 12:29 last edited by
        #3

        That helped a lot indeed!

        reimplementing the resizeEvent() and paintEvent() functions of QGLWidget did the trick!

        Thanks again for always helping out, it is very much appreciated :)

        1 Reply Last reply
        0

        1/3

        23 Sept 2013, 08:12

        • Login

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