diff --git a/src/Demos/osgpbuffer/osgpbuffer.cpp b/src/Demos/osgpbuffer/osgpbuffer.cpp index b87b5c788..db0be8456 100644 --- a/src/Demos/osgpbuffer/osgpbuffer.cpp +++ b/src/Demos/osgpbuffer/osgpbuffer.cpp @@ -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 arguments; - for(int i=1;i