Hi Christoffer, The OSG does absolutely nothing with standard input, go have a look at the whole source code base. standard error and standard output are used for debug and info messages but nothing is read.
So... this has to be a non OSG specific programming question, which I suspect is likely to be down to a platform oddity on the platform you are using. Using standard input is a bit unusual for a rendering application, might I suggest you just read the keyboard input from the actual rendering window itself? Robert. On 11 September 2012 09:20, Christoffer Pettersson <hoffe...@hotmail.com> wrote: > 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 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org