| 28 | | osgProducer::Viewer viewer(arguments); |
| 29 | | |
| 30 | | // set up the value with sensible default event handlers. |
| 31 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 32 | | |
| 33 | | // get details on keyboard and mouse bindings used by the viewer. |
| 34 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 35 | | |
| 36 | | // if user request help write it out to cout. |
| 37 | | if (arguments.read("-h") || arguments.read("--help")) |
| 38 | | { |
| 39 | | arguments.getApplicationUsage()->write(std::cout); |
| 40 | | return 1; |
| 41 | | } |
| 42 | | |
| 43 | | // any option left unread are converted into errors to write out later. |
| 44 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 45 | | |
| 46 | | // report any errors if they have occured when parsing the program aguments. |
| 47 | | if (arguments.errors()) |
| 48 | | { |
| 49 | | arguments.writeErrorMessages(std::cout); |
| 50 | | return 1; |
| 51 | | } |
| 52 | | |
| 53 | | if (arguments.argc()<=1) |
| 54 | | { |
| 55 | | arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); |
| 56 | | return 1; |
| 57 | | } |
| | 22 | osgViewer::Viewer viewer; |
| 130 | | // create the windows and run the threads. |
| 131 | | viewer.realize(); |
| 132 | | |
| 133 | | while( !viewer.done() ) |
| 134 | | { |
| 135 | | // wait for all cull and draw threads to complete. |
| 136 | | viewer.sync(); |
| 137 | | |
| 138 | | // update the scene by traversing it with the the update visitor which will |
| 139 | | // call all node update callbacks and animations. |
| 140 | | viewer.update(); |
| 141 | | |
| 142 | | // fire off the cull and draw traversals of the scene. |
| 143 | | viewer.frame(); |
| 144 | | |
| 145 | | } |
| 146 | | |
| 147 | | // wait for all cull and draw threads to complete. |
| 148 | | viewer.sync(); |
| 149 | | |
| 150 | | // run a clean up frame to delete all OpenGL objects. |
| 151 | | viewer.cleanup_frame(); |
| 152 | | |
| 153 | | // wait for all the clean up frame to complete. |
| 154 | | viewer.sync(); |
| 155 | | |
| 156 | | return 0; |
| | 96 | return viewer.run(); |