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



  • 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?


  • Lifetime Qt Champion

    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



  • 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 :)


Log in to reply
 

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