I would like to run this pseudo-code with OpenSceneGraph:
while (!done) {
addNodeToSceneGraph();
displayCurrentSceneGraph();
waitForKeyPressed();
}
How can I implement it, preferably using the standard OSG API?
EDIT
Here is a concrete example:
int main() {
osgViewer::Viewer viewer;
osg::Geode* geode = new osg::Geode();
viewer.setSceneData(geode);
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0, 0, 0), 1)));
viewer.frame();
this_thread::sleep_for(seconds(2));
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(2, 0, 0), 1)));
return viewer.run();
}
I would like the call to viewer.frame()
above, display the first sphere and after 2s the second sphere would get displayed. It displays a blank screen for 2s instead. What do I have to change?