Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: the right way to share contexts ?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Sep 2008
    Posts
    127

    the right way to share contexts ?

    Hello,
    how do I share contexts of different threads correctly ?
    I create a main render context in the main thread.
    Where do I have to create the second thread? The second thread
    does so loading stuff. Guess I should create the second one in
    the second thread right ? But when sharing the context, in what
    thread should I call wglShareLists ?

    thanks,
    lobbel

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352

    Re: the right way to share contexts ?

    it's not important you can even create both contexes at the beginnig an then call wglShareList. The important part is the wglMakeCurrent, each thread must have its current thread.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2010
    Posts
    12

    Re: the right way to share contexts ?

    Contexts are like global variables so you can create them all in your main thread. Then use wglShareLists with each context in your main thread. After that, you can call wglMakeCurrent from a thread and it will will bind the context to that thread.

    I don't think it matters what thread you call wglShareList from, but it only works with contexts that are not currently bound so it should be called first.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •