Results 1 to 2 of 2

Thread: QGLWidget multithreaded example?

  1. #1
    Join Date
    Mar 2008
    Location
    Venezuela
    Posts
    34
    Thanks
    4
    Platforms
    MacOS X Unix/X11

    Question QGLWidget multithreaded example?

    Hi, I'm working with OpenGL and QGLWidget, but I'd like to do some animations on rotation and zoom operations, so I'm trying to find some examples of how to do multithreaded drawings with OpenGL. At first sight, I wasn't able to find any examples on this subject in QtAssistant.

    I guess I must share the QGLContext between the GUI and the animation thread, calling makeCurrent() and doneCurrent() at beginning/end of the animation, and waking up the thread each N seconds, where N is the time step between each frame, and swapping buffers. But I wonder how could I define a common interface for all my animations?

  2. #2
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGLWidget multithreaded example?

    Quote Originally Posted by danielperaza View Post
    Hi, I'm working with OpenGL and QGLWidget, but I'd like to do some animations on rotation and zoom operations, so I'm trying to find some examples of how to do multithreaded drawings with OpenGL. At first sight, I wasn't able to find any examples on this subject in QtAssistant.

    I guess I must share the QGLContext between the GUI and the animation thread, calling makeCurrent() and doneCurrent() at beginning/end of the animation, and waking up the thread each N seconds, where N is the time step between each frame, and swapping buffers. But I wonder how could I define a common interface for all my animations?
    I was also trying to achieve the same thing a while ago. After bit of digging, I have learned the followings.

    "OpenGL machine state is not designed to be multithreaded."

    This means a single rendering context is meant to be used by one thread. I attempted to create multiple rendering contexts and let them render different frames (i.e. even number frames in context 1 and odd number frames in context 2). This sounds like "multithreading" but then when you call "makeCurrent()", it means from that moment until doneCurrent() or another makeCurrent(), the OpenGL machine is dedicated to the current rendering context only which means it acts as kind of mutex mechanism.

    I also learned that this will be changed in future (even now) so if in your hardware, graphic card has more than one GPU then multithreading might occur but then this may also not be true unless the driver in your OS supports dual GPU stuff.

    Regards,
    Dong Back Kim

Similar Threads

  1. Multithreaded server
    By virus in forum Newbie
    Replies: 1
    Last Post: 23rd February 2011, 07:28
  2. Multithreaded OpenGL
    By spraff in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2010, 16:55
  3. Multithreaded Server
    By niol1000 in forum Newbie
    Replies: 1
    Last Post: 24th February 2010, 17:33
  4. Qt + gprof in a multithreaded app?
    By papercut in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2009, 17:12
  5. Designing Multithreaded app in Qt
    By summer_of_69 in forum Qt Programming
    Replies: 3
    Last Post: 18th June 2009, 15:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.