View Full Version : Can OpenGL support multithread?
06-23-2003, 01:16 AM
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.
06-23-2003, 03:00 AM
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.
06-24-2003, 12:51 AM
Can you tell me how to make two threads render in the same or different context?
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.
06-24-2003, 06:16 PM
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).]
06-24-2003, 07:43 PM
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.
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.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.