Results 1 to 10 of 46

Thread: Multithreaded resource loading

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I was trying to make my OpenGL imageviewer threaded but no luck so far. The program keeps 3 images loaded same time and they are scrolled up and down continuously. You can imagine there is a small pause when scroll reach the ends and needs to load next file.

    I was hoping command glFinish would do the trick for me but it seemed to be more complicated problem...

    Edit: And i tested your program, it run good and all images loaded normally. Only windows taskbar button was showing a generic application icon instead of the icon that was in .exe and application titlebar.

    cpu: E8400 3Ghz dualcore
    gpu: Radeon HD 5700
    Last edited by User137; 03-10-2010 at 09:58 PM.

  2. #2
    Quote Originally Posted by User137
    I was hoping command glFinish would do the trick for me but it seemed to be more complicated problem...
    Yeah, there is some tricky way for using multithreaded texture loading under Windows

    1. Create context in main thread
    2. Call wglMakeCurrent( 0, 0 ) in main thread and create second thread
    3. Create new context using main device context(HDC) in second thread and make it current
    4. Call wglShareLists( context_from_main_thread, new_context ) in second thread
    5. Call wglMakeCurrent for main context in main thread

    So, after this you can load resources in second thread and use them in main thread. But you must be careful with other operations, like binding texture before it was loaded in second thread(seems this is my error in demo, but this happens not on all PC's)

    Quote Originally Posted by User137
    Only windows taskbar button was showing a generic application icon instead of the icon that was in .exe and application titlebar.
    Hmm, there is no icon in exe. I compiled it wthout resource file.
    Last edited by Andru; 03-10-2010 at 10:25 PM.

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Hey is this a Windows demo? If you provide me with a Snow Leopard compatible demo I'd gladly run it on my, almost newest, iMac (has an Intel Core i7 with a ATI Radeon HD 4850) for you.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #4
    Hey is this a Windows demo? If you provide me with a Snow Leopard compatible demo I'd gladly run it on my, almost newest, iMac (has an Intel Core i7 with a ATI Radeon HD 4850) for you.
    Oh, it will be interesting to test it on real Mac Tonight I will build a Mac demo.

  5. #5
    Are you doing this with Lazarus? It has lazOpenGLContext package which works same time on most operating systems.

  6. #6
    Quote Originally Posted by User137
    Are you doing this with Lazarus? It has lazOpenGLContext package which works same time on most operating systems.
    Nope, I use my own code(that can be compiled by FreePascal and Delphi(7-2010, Win32 only)). Maybe some time later I will present my library with examples here

  7. #7
    Cool stuff! programs seems to work ok here. I experimented with this a while back see we use the same approach. You can not only load textures this way but also geometry into VBO/DPL, load and compile shader programs or any other OpenGL resource for that matter.

    To bad that this approach requires a context switch I made a small grid bassed world system that would automaticly stream in new models/textures when needed but the switching of contexts gave me pretty large framedrops. Hope that OGL 4.X wil have a solution for this like DX10 and DX11.

Tags for this Thread

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
  •