| 118 | | // use an ArgumentParser object to manage the program arguments. |
| 119 | | osg::ArgumentParser arguments(&argc,argv); |
| 120 | | |
| 121 | | // set up the usage document, in case we need to print out how to use this program. |
| 122 | | arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates both text, animation and billboard via custom transform to create the OpenSceneGraph logo.."); |
| 123 | | arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); |
| 124 | | arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); |
| 125 | | arguments.getApplicationUsage()->addCommandLineOption("ps","Render the Professional Services logo"); |
| 126 | | |
| 128 | | osgProducer::Viewer viewer(arguments); |
| 129 | | |
| 130 | | // set up the value with sensible default event handlers. |
| 131 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 132 | | |
| 133 | | // get details on keyboard and mouse bindings used by the viewer. |
| 134 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 135 | | |
| 136 | | // if user request help write it out to cout. |
| 137 | | if (arguments.read("-h") || arguments.read("--help")) |
| 138 | | { |
| 139 | | arguments.getApplicationUsage()->write(std::cout); |
| 140 | | return 1; |
| 141 | | } |
| 142 | | |
| 143 | | // any option left unread are converted into errors to write out later. |
| 144 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 145 | | |
| 146 | | // report any errors if they have occured when parsing the program aguments. |
| 147 | | if (arguments.errors()) |
| 148 | | { |
| 149 | | arguments.writeErrorMessages(std::cout); |
| 150 | | return 1; |
| 151 | | } |
| | 119 | osgViewer::Viewer viewer; |
| 160 | | // create the windows and run the threads. |
| 161 | | viewer.realize(); |
| 162 | | |
| 163 | | while( !viewer.done() ) |
| 164 | | { |
| 165 | | |
| 166 | | // wait for all cull and draw threads to complete. |
| 167 | | viewer.sync(); |
| 168 | | |
| 169 | | // update the scene by traversing it with the the update visitor which will |
| 170 | | // call all node update callbacks and animations. |
| 171 | | viewer.update(); |
| 172 | | |
| 173 | | // fire off the cull and draw traversals of the scene. |
| 174 | | viewer.frame(); |
| 175 | | } |
| 176 | | |
| 177 | | // wait for all cull and draw threads to complete. |
| 178 | | viewer.sync(); |
| 179 | | |
| 180 | | // run a clean up frame to delete all OpenGL objects. |
| 181 | | viewer.cleanup_frame(); |
| 182 | | |
| 183 | | // wait for all the clean up frame to complete. |
| 184 | | viewer.sync(); |
| 185 | | |
| 186 | | return 0; |
| | 128 | return viewer.run(); |