| 347 | | // use an ArgumentParser object to manage the program arguments. |
| 348 | | osg::ArgumentParser arguments(&argc,argv); |
| 349 | | |
| 350 | | // set up the usage document, in case we need to print out how to use this program. |
| 351 | | arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of particle systems."); |
| 352 | | arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] image_file_left_eye image_file_right_eye"); |
| 353 | | arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); |
| 354 | | |
| 355 | | |
| 357 | | osgProducer::Viewer viewer(arguments); |
| 358 | | |
| 359 | | // set up the value with sensible default event handlers. |
| 360 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 361 | | |
| 362 | | // get details on keyboard and mouse bindings used by the viewer. |
| 363 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 364 | | |
| 365 | | // if user request help write it out to cout. |
| 366 | | if (arguments.read("-h") || arguments.read("--help")) |
| 367 | | { |
| 368 | | arguments.getApplicationUsage()->write(std::cout); |
| 369 | | return 1; |
| 370 | | } |
| 371 | | |
| 372 | | // any option left unread are converted into errors to write out later. |
| 373 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 374 | | |
| 375 | | // report any errors if they have occured when parsing the program aguments. |
| 376 | | if (arguments.errors()) |
| 377 | | { |
| 378 | | arguments.writeErrorMessages(std::cout); |
| 379 | | return 1; |
| 380 | | } |
| | 348 | osgViewer::Viewer viewer; |
| 388 | | // create the windows and run the threads. |
| 389 | | viewer.realize(); |
| 390 | | |
| 391 | | while( !viewer.done() ) |
| 392 | | { |
| 393 | | // wait for all cull and draw threads to complete. |
| 394 | | viewer.sync(); |
| 395 | | |
| 396 | | // update the scene by traversing it with the the update visitor which will |
| 397 | | // call all node update callbacks and animations. |
| 398 | | viewer.update(); |
| 399 | | |
| 400 | | // fire off the cull and draw traversals of the scene. |
| 401 | | viewer.frame(); |
| 402 | | |
| 403 | | } |
| 404 | | |
| 405 | | // wait for all cull and draw threads to complete. |
| 406 | | viewer.sync(); |
| 407 | | |
| 408 | | // run a clean up frame to delete all OpenGL objects. |
| 409 | | viewer.cleanup_frame(); |
| 410 | | |
| 411 | | // wait for all the clean up frame to complete. |
| 412 | | viewer.sync(); |
| 413 | | |
| 414 | | return 0; |
| | 356 | return viewer.run(); |