| 145 | | |
| 146 | | |
| 147 | | // set up the value with sensible default event handlers. |
| 148 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 149 | | |
| 150 | | viewer.getEventHandlerList().push_front(new TechniqueEventHandler(blendEquation)); |
| 151 | | |
| 152 | | // get details on keyboard and mouse bindings used by the viewer. |
| 153 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 154 | | |
| 155 | | // if user request help write it out to cout. |
| 156 | | if (arguments.read("-h") || arguments.read("--help")) |
| 157 | | { |
| 158 | | arguments.getApplicationUsage()->write(std::cout); |
| 159 | | return 1; |
| 160 | | } |
| 161 | | |
| 162 | | // any option left unread are converted into errors to write out later. |
| 163 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 164 | | |
| 165 | | // report any errors if they have occured when parsing the program aguments. |
| 166 | | if (arguments.errors()) |
| 167 | | { |
| 168 | | arguments.writeErrorMessages(std::cout); |
| 169 | | return 1; |
| 170 | | } |
| 171 | | |
| 172 | | if (arguments.argc()<=1) |
| 173 | | { |
| 174 | | arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); |
| 175 | | return 1; |
| 176 | | } |
| 177 | | |
| 178 | | |
| 187 | | // create the windows and run the threads. |
| 188 | | viewer.realize(); |
| 189 | | |
| 190 | | while( !viewer.done() ) |
| 191 | | { |
| 192 | | // wait for all cull and draw threads to complete. |
| 193 | | viewer.sync(); |
| 194 | | |
| 195 | | // update the scene by traversing it with the the update visitor which will |
| 196 | | // call all node update callbacks and animations. |
| 197 | | viewer.update(); |
| 198 | | |
| 199 | | // fire off the cull and draw traversals of the scene. |
| 200 | | viewer.frame(); |
| 201 | | |
| 202 | | } |
| 203 | | |
| 204 | | // wait for all cull and draw threads to complete. |
| 205 | | viewer.sync(); |
| 206 | | |
| 207 | | // run a clean up frame to delete all OpenGL objects. |
| 208 | | viewer.cleanup_frame(); |
| 209 | | |
| 210 | | // wait for all the clean up frame to complete. |
| 211 | | viewer.sync(); |
| 212 | | |
| 213 | | return 0; |
| | 155 | return viewer.run(); |