Made the custom window set up a runtime option

This commit is contained in:
Robert Osfield 2007-01-05 13:15:59 +00:00
parent a42633a9ee
commit 348fc7bdb3

View File

@ -114,8 +114,6 @@ int main( int argc, char **argv )
// construct the viewer. // construct the viewer.
osgViewer::Viewer viewer; osgViewer::Viewer viewer;
viewer.setCameraManipulator(new GliderManipulator());
// if user request help write it out to cout. // if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help")) if (arguments.read("-h") || arguments.read("--help"))
{ {
@ -123,24 +121,12 @@ int main( int argc, char **argv )
return 1; return 1;
} }
// any option left unread are converted into errors to write out later. bool customWindows = false;
arguments.reportRemainingOptionsAsUnrecognized(); while(arguments.read("-1")) customWindows = true;
while(arguments.read("-2")) customWindows = false;
// report any errors if they have occured when parsing the program aguments. if (customWindows)
if (arguments.errors())
{ {
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) rootnode = createModel();
viewer.setSceneData( rootnode );
#if 0
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi) if (!wsi)
{ {
@ -159,11 +145,11 @@ int main( int argc, char **argv )
traits->y = 500; traits->y = 500;
traits->width = width; traits->width = width;
traits->height = height; traits->height = height;
#if 0 #if 0
traits->windowDecoration = false; traits->windowDecoration = false;
#else #else
traits->windowDecoration = true; traits->windowDecoration = true;
#endif #endif
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
@ -194,25 +180,19 @@ int main( int argc, char **argv )
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::scale(aspectRatioScale,1.0,1.0)); viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::scale(aspectRatioScale,1.0,1.0));
} }
}
viewer.setUpRenderingSupport(); else
viewer.assignSceneDataToCameras();
#else
viewer.setUpViewAcrossAllScreens();
#endif
viewer.realize();
while( !viewer.done() )
{ {
// fire off the cull and draw traversals of the scene. viewer.setUpViewAcrossAllScreens();
viewer.frame();
} }
return 0; // set up the camera manipulation with out custom manipultor
viewer.setCameraManipulator(new GliderManipulator());
// pass the scene graph to the viewer
viewer.setSceneData( createModel() );
return viewer.run();
} }