Re: [Plib-users] Threading
Brought to you by:
sjbaker
From: Curtis L. O. <cu...@me...> - 2001-04-11 22:45:12
|
Steve Baker writes: > Yes...if *all* the PLIB calls happen in that one thread - and all the OpenGL > calls in that same thread - then there should be no problems. > > What you can't do is things like playing with the scene graph in one thread > and rendering it in the other because there is no internal protection against > that kind of thing. > > With extreme care, you could do things like building a new section of > scene graph in one thread - and rendering a disconnected part of the > scene graph in another - then when both processes finish working, connecting > the new scene graph segment into the main tree. Similarly, you could > disconnect a section of the tree (when you know the rendering thread > is idle) and delete it in the other thread. > > Those things are tricky and not 100% guaranteed - but for what you describe, > there shouldn't be a problem. We have just begun to explore the idea of updating the scene graph tree in a seperate thread from the main render thread. Clearly you must never do anything in the update thread that could ever trigger an opengl command (such as loading/registering a texture for example.) However, other than that we have been surprised that it has worked pretty well and is very robust. Do know that threads are not necessarily nirvana, and unless you really know what you are doing and exactly what the threading will accomplish for you in advance, I'd recommend staying away from them as long as you can. You can do an amazing amount without them if you try. If you do add threading, know that you are introducing a new layer of complexity in terms of software design, as well as in terms of debugging, and many assumptions your code may have made in the past might come around to bite you once you add threading ... and bite you in subtle hard to debug ways ... at inopportune times ... But heck, I'm not listening to my own advice so I suppose I shouldn't expect anyone else to ... :-) Curt. -- Curtis Olson Human Factors Research Lab Flight Gear Project Twin Cities cu...@hf... cu...@fl... Minnesota http://www.menet.umn.edu/~curt http://www.flightgear.org |