[osg-users] Threading with OSG
tonio_73 at tiscali.fr
Thu Oct 25 11:11:01 PDT 2007
Daniel Moos wrote:
> Hi everybody
> I have a complex model. From this model i calculate the silhouette edges. This
> calculation need some seconds.
> If i calculate this the view isn't updated.
> How can i create a thread for this calculation? Or how can I show a message on
> a osgText::Text before calculating the edges?
About the text update, it is more about thread synchronization than OSG.
The basic to update a text in OSG is to keep a pointer (better, a smart
pointer) to the osgText::Text object. Update is performed calling
setText(std::string ) on this object.
This update cannot happen in the worker thread since it may happen while
the viewer is culling or drawing.
I suggest to add a text update check during the update phase of the
viewer (main loop), if text's std::string has been updated, modify
osgText::Text object otherwise, skip. Mutex is needed to protect the
std::string and status flag (better a flag than a string comparison)
shared by both threads.
More information about the osg-users