Hi,

I searched the forum and was enspired by the following Topic:
http://www.mail-archive.com/[email protected]/msg08183.html

I tried to create separate thread which will run from main function and  run 
LoadNodefile. 


Code:

class MyThread : public OpenThreads::Thread 
{ 
public: 
        MyThread(osg::Node* node) : _done(false),_node(node) { /* ... */ } 
virtual ~MyThread() { /* ... */ } 
virtual void run() 
{ 
        _node = osgDB::readNodeFile("cow.osg");
}

void stopWorking() 
{
_done = true;
 join();
} 
protected: 
bool _done; 
osg::Node* _node;
};

int main()
{

osg::Node* node = NULL;
osg::Group* root = new osg::Group();

MyThread* myThread = new MyThread(node);
myThread->start(); 

root->addChild(node);

osgViewer::Viewer viewer;

root->addChild(node);
viewer.setSceneData( root );

viewer.addEventHandler(new osgViewer::ThreadingHandler);

while( !viewer.done() )
{
   ......
}
}





The value of node is null. I'm a newbie in Threading Programming, but I need to 
find a way to work it out. 

could anybody help?

Thank you!

Cheers,
Danny

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=24146#24146





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to