[osg-users] addSlave messup main cameras stateset

suneel suresh compressor at gmail.com
Tue Apr 19 11:34:32 PDT 2011

thank you for getting back robet, i agree that i didnt present all the code, however its mostly standard from the examples.

one thing i ought to mention is that i am using osg with wxWidgets. I tried to go back and look at the code and i found that even if i just add a new camera it screws with the state set. In the handler function code below i  print the pointer before and after add slave. first time i get an address, second time its null


osgViewer::Viewer *viewer = cloudglobals::rootFrame->osg_viewer;
osg::StateSet *stateSet = viewer->getCamera()->getOrCreateStateSet();
osg::Point *pointState = (osg::Point*)stateSet->getAttribute(osg::StateAttribute::POINT);
cout{{"# "{{pointState{{" "; // this is NOT NULL (how to add angular brkts for cout?)
viewer->addSlave(new osg::Camera, false); // add slave camera to viewer
stateSet = viewer->getCamera()->getOrCreateStateSet();
pointState = (osg::Point*)stateSet->getAttribute(osg::StateAttribute::POINT);

Read this topic online here:

More information about the osg-users mailing list