| 247 | | osgProducer::Viewer viewer(arguments); |
| 248 | | |
| 249 | | // set up the value with sensible default event handlers. |
| 250 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 251 | | |
| 252 | | // get details on keyboard and mouse bindings used by the viewer. |
| 253 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 254 | | |
| 255 | | // if user request help write it out to cout. |
| 256 | | if (arguments.read("-h") || arguments.read("--help")) |
| 257 | | { |
| 258 | | arguments.getApplicationUsage()->write(std::cout); |
| 259 | | return 1; |
| 260 | | } |
| 261 | | |
| 262 | | // any option left unread are converted into errors to write out later. |
| 263 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 264 | | |
| 265 | | // report any errors if they have occured when parsing the program aguments. |
| 266 | | if (arguments.errors()) |
| 267 | | { |
| 268 | | arguments.writeErrorMessages(std::cout); |
| 269 | | return 1; |
| 270 | | } |
| | 242 | osgViewer::Viewer viewer; |
| 277 | | |
| 278 | | // create the windows and run the threads. |
| 279 | | viewer.realize(); |
| 280 | | |
| 281 | | while (!viewer.done()) |
| 282 | | { |
| 283 | | // wait for all cull and draw threads to complete. |
| 284 | | viewer.sync(); |
| 285 | | |
| 286 | | // update the scene by traversing it with the the update visitor which will |
| 287 | | // call all node update callbacks and animations. |
| 288 | | viewer.update(); |
| 289 | | |
| 290 | | // fire off the cull and draw traversals of the scene. |
| 291 | | viewer.frame(); |
| 292 | | } |
| 293 | | |
| 294 | | // wait for all cull and draw threads to complete. |
| 295 | | viewer.sync(); |
| 296 | | |
| 297 | | // run a clean up frame to delete all OpenGL objects. |
| 298 | | viewer.cleanup_frame(); |
| 299 | | |
| 300 | | // wait for all the clean up frame to complete. |
| 301 | | viewer.sync(); |
| 302 | | |
| 303 | | return 0; |
| 304 | | } |
| | 249 | |
| | 250 | return viewer.run(); |
| | 251 | } |