Results 1 to 5 of 5

Thread: QOpenGL in threads

  1. #1
    Join Date
    Jan 2009
    Location
    Prague, CZE
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb QOpenGL in threads

    Hi,

    i am writing program with some threads and one thread painting some stream to QGLWidget.

    If it runs as one thread application, painting is ok.

    If it runs as multithread application (one thread for painting and others are for some control operations), painting is bad (painting starting not in the corner but at random position).

    I tried lot of modifications, but it seems, that problem is threads.

    I found in doc : "Please note that QGLContext is not thread safe."


    Is there any possible to sovle this problem? please help.

  2. #2
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QOpenGL in threads

    I don't how you render, but OpenGL is not thread safe.

  3. #3
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QOpenGL in threads

    Quote Originally Posted by wydesenej View Post
    Is there any possible to sovle this problem? please help.
    I never tried glWidget inside a thread, can you post your render n glpaint function please?
    Maybe we can resolve this, despite incompatibility of opengl with threads.

  4. #4
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QOpenGL in threads

    Quote Originally Posted by wydesenej View Post
    Hi,
    Is there any possible to sovle this problem? please help.
    As far as GPU is doing all the work asynchronously, CPU threads are pointless. Therefore, your application would always be single-threaded. (at least for rendering)

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QOpenGL in threads

    Quote Originally Posted by saman_artorious View Post
    As far as GPU is doing all the work asynchronously, CPU threads are pointless. Therefore, your application would always be single-threaded. (at least for rendering)
    That's not exactly true. You still have to push data into the GL pipeline using CPU.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Threads in Qt
    By freekill in forum Qt Programming
    Replies: 4
    Last Post: 11th November 2009, 19:49
  2. Visualization and Threads
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2009, 14:13
  3. Qt threads
    By ^Nisok^ in forum Newbie
    Replies: 12
    Last Post: 22nd April 2009, 15:35
  4. Threads...
    By Abc in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2008, 18:35
  5. Once more: Threads in Qt4
    By high_flyer in forum Qt Programming
    Replies: 5
    Last Post: 9th August 2006, 19:35

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.