| 100 | | |
| 101 | | // set up the usage document, in case we need to print out how to use this program. |
| 102 | | arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use multi-pass and osg::ClipNode to clip parts of the scene away.."); |
| 103 | | arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); |
| 104 | | arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); |
| 105 | | |
| 106 | | // initialize the viewer. |
| 107 | | osgProducer::Viewer viewer(arguments); |
| 108 | | |
| 109 | | // set up the value with sensible default event handlers. |
| 110 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 111 | | |
| 112 | | // get details on keyboard and mouse bindings used by the viewer. |
| 113 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 114 | | |
| 115 | | // if user request help write it out to cout. |
| 116 | | if (arguments.read("-h") || arguments.read("--help")) |
| 117 | | { |
| 118 | | arguments.getApplicationUsage()->write(std::cout); |
| 119 | | return 1; |
| 120 | | } |
| 121 | | |
| 122 | | // any option left unread are converted into errors to write out later. |
| 123 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 124 | | |
| 125 | | // report any errors if they have occured when parsing the program aguments. |
| 126 | | if (arguments.errors()) |
| 127 | | { |
| 128 | | arguments.writeErrorMessages(std::cout); |
| 129 | | return 1; |
| 130 | | } |
| 131 | | |
| 132 | | if (arguments.argc()<=1) |
| 133 | | { |
| 134 | | arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); |
| 135 | | return 1; |
| 136 | | } |
| 157 | | // create the windows and run the threads. |
| 158 | | viewer.realize(); |
| 159 | | |
| 160 | | while( !viewer.done() ) |
| 161 | | { |
| 162 | | // wait for all cull and draw threads to complete. |
| 163 | | viewer.sync(); |
| 164 | | |
| 165 | | // update the scene by traversing it with the the update visitor which will |
| 166 | | // call all node update callbacks and animations. |
| 167 | | viewer.update(); |
| 168 | | |
| 169 | | // fire off the cull and draw traversals of the scene. |
| 170 | | viewer.frame(); |
| 171 | | |
| 172 | | } |
| 173 | | |
| 174 | | // wait for all cull and draw threads to complete. |
| 175 | | viewer.sync(); |
| 176 | | |
| 177 | | // run a clean up frame to delete all OpenGL objects. |
| 178 | | viewer.cleanup_frame(); |
| 179 | | |
| 180 | | // wait for all the clean up frame to complete. |
| 181 | | viewer.sync(); |
| 182 | | |
| 183 | | return 0; |
| | 121 | return viewer.run(); |