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 7 of 7

Thread: Can OpenGL support multithread?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2003
    Location
    Kochi, Japan
    Posts
    29

    Can OpenGL support multithread?

    In my program, I want to utilize two threads to improve the efficiency.How can I do? My tool is Visual C++6.0,and my OS is Windows2000 Professional.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,651

    Re: Can OpenGL support multithread?

    Hi !

    Yes you can, but be aware the one rendering context can only be active in one thread at the time so some care need to be taken to make it work.

    Mikael

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2003
    Location
    Kochi, Japan
    Posts
    29

    Re: Can OpenGL support multithread?

    Can you tell me how to make two threads render in the same or different context?

  4. #4
    Guest

    Re: Can OpenGL support multithread?

    If you want to render to the same context from different threads do you have to do the synchronizing yourself.
    Rendering to different contexts is handled by OpenGL if I have not forgot something. Just do the usual stuff and make each context active from the different threads.

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2003
    Location
    Kochi, Japan
    Posts
    29

    Re: Can OpenGL support multithread?

    Do you mean that if I want to render to different contexts I should set the rendering context at the beginning of each thread,while if I want to render to the same context I should share the same rendering context? How can I do that? Is there any example?

    [This message has been edited by jiangerlai (edited 06-24-2003).]

  6. #6
    Junior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Nanjing,China
    Posts
    118

    Re: Can OpenGL support multithread?

    Using more than one thread to draw Opengl does not boost your application a lot since much of the processing time is in the graphics side.I suggest stick to one thread to draw and you may or maynot use another thread to do some pre-drawing calculation.

  7. #7
    Guest

    Re: Can OpenGL support multithread?

    You can set the rendering context at the beginning of each thread but more general can MakeCurrent be called anytime to change the context for the thread. See the documentation for the function.
    If you want to share a context is it like sharing any resource between threads. Put it in a critical section with a call to MakeCurrent first.
    The only sample code I know of is from Mesa and works under unix.
    Using multiple threads like this is costing performance.

Posting Permissions

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