Results 1 to 4 of 4

Thread: Qt5 texture upload in separate thread

  1. #1
    Join Date
    May 2007
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt5 texture upload in separate thread

    Hi,

    I'm trying to implement async loading of textures by using a shared GL context in a separate thread and uploading textures into it. In Qt4 this could be done by using a hidden QGLWidget. As described in the QGLWidget documentation:

    Doing texture uploads in a thread may be very useful for applications handling large amounts of images that needs to be displayed, like for instance a photo gallery application. This is supported in Qt through the existing bindTexture() API. A simple way of doing this is to create two sharing QGLWidgets. One is made current in the main GUI thread, while the other is made current in the texture upload thread. The widget in the uploading thread is never shown, it is only used for sharing textures with the main thread. For each texture that is bound via bindTexture(), notify the main thread so that it can start using the texture.
    Now, I'm trying to do this in Qt5 with QOpenGLContext and QSurface/QWindow, but I'm not quite sure how. According to the documentation I can't start rendering into a QWindow until it has been exposed.

    Any ideas on how to do this?

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

    Default Re: Qt5 texture upload in separate thread

    Quote Originally Posted by tseval View Post
    According to the documentation I can't start rendering into a QWindow until it has been exposed.
    What do you want to render there?
    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.


  3. #3
    Join Date
    May 2007
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt5 texture upload in separate thread

    I don't want to render anything, I just need a shared context to upload my textures into

    But, assuming that your answer was a rhetorical question it means that I can simply do something like this and it would work?

    Qt Code:
    1. tex_upload_ctx_ = new QOpenGLContext();
    2.  
    3. QSurfaceFormat fmt;
    4. tex_upload_ctx_->setFormat(fmt);
    5. tex_upload_ctx_->setShareContext(main_ctx);
    6. tex_upload_ctx_->create();
    7.  
    8. tex_upload_win_ = new QWindow();
    9. tex_upload_ctx_->makeCurrent(tex_upload_win_);
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Qt5 texture upload in separate thread

    Yes, I think you can do exactly that. It's the shared context you want/need, not another window.
    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. GUI Updates from separate Thread
    By sa5webber in forum Newbie
    Replies: 5
    Last Post: 16th June 2012, 20:08
  2. Put in a separate thread a method of a class
    By franco.amato in forum Qt Programming
    Replies: 0
    Last Post: 19th March 2010, 23:45
  3. update widget from separate thread
    By method in forum Qt Programming
    Replies: 5
    Last Post: 10th July 2009, 14:33
  4. new QWidget in separate thread
    By magland in forum Qt Programming
    Replies: 15
    Last Post: 7th February 2008, 12:32
  5. handling paintGL in a separate thread
    By al101 in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2007, 17:04

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.