Changeset 5927 for OpenSceneGraph/trunk/examples/osglogicop/osglogicop.cpp
- Timestamp:
- 01/08/07 11:00:16 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osglogicop/osglogicop.cpp
r5636 r5927 7 7 #include <osgDB/ReadFile> 8 8 9 #include <osg Producer/Viewer>9 #include <osgViewer/Viewer> 10 10 11 11 #include <osgUtil/Optimizer> 12 13 #include <iostream> 12 14 13 15 const int _ops_nb=16; … … 119 121 int main( int argc, char **argv ) 120 122 { 121 122 123 // use an ArgumentParser object to manage the program arguments. 123 124 osg::ArgumentParser arguments(&argc,argv); 124 125 // set up the usage document, in case we need to print out how to use this program.126 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates how to use glLogicOp for mixing rendered scene and the frame-buffer.");127 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");128 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");129 130 // construct the viewer.131 osgProducer::Viewer viewer(arguments);132 125 133 126 // load the nodes from the commandline arguments. … … 135 128 if (!loadedModel) 136 129 { 130 osg::notify(osg::NOTICE)<<"Please specify model filename on the command line."<<std::endl; 137 131 return 1; 138 132 } … … 140 134 osg::Group* root = new osg::Group; 141 135 root->addChild(loadedModel); 142 143 136 144 137 osg::StateSet* stateset = new osg::StateSet; … … 153 146 loadedModel->setStateSet(stateset); 154 147 148 // construct the viewer. 149 osgViewer::Viewer viewer; 155 150 156 157 158 // set up the value with sensible default event handlers. 159 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 160 161 viewer.getEventHandlerList().push_front(new TechniqueEventHandler(logicOp)); 162 163 // get details on keyboard and mouse bindings used by the viewer. 164 viewer.getUsage(*arguments.getApplicationUsage()); 165 166 // if user request help write it out to cout. 167 if (arguments.read("-h") || arguments.read("--help")) 168 { 169 arguments.getApplicationUsage()->write(std::cout); 170 return 1; 171 } 172 173 // any option left unread are converted into errors to write out later. 174 arguments.reportRemainingOptionsAsUnrecognized(); 175 176 // report any errors if they have occured when parsing the program aguments. 177 if (arguments.errors()) 178 { 179 arguments.writeErrorMessages(std::cout); 180 return 1; 181 } 182 183 if (arguments.argc()<=1) 184 { 185 arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 186 return 1; 187 } 188 189 151 viewer.addEventHandler(new TechniqueEventHandler(logicOp)); 190 152 191 153 // run optimization over the scene graph … … 196 158 viewer.setSceneData( root ); 197 159 198 // create the windows and run the threads. 199 viewer.realize(); 200 201 while( !viewer.done() ) 202 { 203 // wait for all cull and draw threads to complete. 204 viewer.sync(); 205 206 // update the scene by traversing it with the the update visitor which will 207 // call all node update callbacks and animations. 208 viewer.update(); 209 210 // fire off the cull and draw traversals of the scene. 211 viewer.frame(); 212 } 213 214 // wait for all cull and draw threads to complete. 215 viewer.sync(); 216 217 // run a clean up frame to delete all OpenGL objects. 218 viewer.cleanup_frame(); 219 220 // wait for all the clean up frame to complete. 221 viewer.sync(); 222 223 return 0; 160 return viewer.run(); 224 161 }
