| 317 | | |
| 318 | | // use an ArgumentParser object to manage the program arguments. |
| 319 | | osg::ArgumentParser arguments(&argc,argv); |
| 320 | | |
| 321 | | // set up the usage document, in case we need to print out how to use this program. |
| 322 | | arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates how to encpsulate OpenGL rendering code via sublcassing of osg::Drawable.."); |
| 323 | | arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); |
| 324 | | arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); |
| 325 | | |
| 327 | | osgProducer::Viewer viewer(arguments); |
| 328 | | |
| 329 | | // set up the value with sensible default event handlers. |
| 330 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 331 | | |
| 332 | | // get details on keyboard and mouse bindings used by the viewer. |
| 333 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 334 | | |
| 335 | | // if user request help write it out to cout. |
| 336 | | if (arguments.read("-h") || arguments.read("--help")) |
| 337 | | { |
| 338 | | arguments.getApplicationUsage()->write(std::cout); |
| 339 | | return 1; |
| 340 | | } |
| 341 | | |
| 342 | | // any option left unread are converted into errors to write out later. |
| 343 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 344 | | |
| 345 | | // report any errors if they have occured when parsing the program aguments. |
| 346 | | if (arguments.errors()) |
| 347 | | { |
| 348 | | arguments.writeErrorMessages(std::cout); |
| 349 | | return 1; |
| 350 | | } |
| | 318 | osgViewer::Viewer viewer; |