Hello, I'm trying to write a program where the renderer is running on a separate thread. On the main thread I want to control the command line inputs but as soon as I add scenedata to the osgViewer which is stored in the renderer then the renderer takes over the standard input. std::cin in the main thread is ignored. If I put std::cin in the renderer thread however the program pauses and expects an input from the command line.
Does anyone know how I can prevent osgViewer from taking over the command line? I have attached sample code to this post where I demonstrate the problem. Code: #include #include #include class MiniRenderer: public OpenThreads::Thread { public: void addModel(osg::Node* node) { _nodes.push_back(node); } void run() { _viewer.setUpViewInWindow(0, 0, 640, 480); _viewer.realize(); _sceneRoot = new osg::Group; _run = true; while(_run) { if(_nodes.size()>0) { for(unsigned int i = 0; i < _nodes.size(); ++i) _sceneRoot->addChild(_nodes[i]); _nodes.clear(); _viewer.setSceneData(_sceneRoot.get()); } int test = -2; std::cout << "In Thread: " << std::endl; std::cin >> test; std::cout << "In Thread : " << test << std::endl; _viewer.frame(); } } bool _run; osg::ref_ptr _sceneRoot; osgViewer::Viewer _viewer; std::vector > _nodes; }; int main( int argc, char **argv ) { std::cout << "Starting thread" << std::endl; MiniRenderer *minirenderer = new MiniRenderer(); mr->startThread(); osg::ref_ptr root = osgDB::readNodeFile("cessna.osg"); minirenderer->addModel(root); int test = -1; std::cout << "Main cin" << std::endl; std::cin >> test; std::cout << "Main cin: " << test << std::endl; while(true) { } return 0; } Kind Regards Hoffe ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=49913#49913 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org