Moved code across to use the new ArgumentParser.

This commit is contained in:
Robert Osfield
2003-03-14 21:01:35 +00:00
parent 7083773b64
commit 59995dde90

View File

@@ -590,32 +590,32 @@ void write_usage(std::ostream& out,const std::string& name)
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
if (argc<2)
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the commandline args.
std::vector<std::string> arguments;
for(int i=1;i<argc;++i) arguments.push_back(argv[i]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(arguments);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(arguments);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);