- Timestamp:
- 01/08/07 11:00:16 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgmultitexture/osgmultitexture.cpp
r5381 r5927 1 #include <osg Producer/Viewer>1 #include <osgViewer/Viewer> 2 2 3 3 #include <osg/Notify> … … 16 16 #include <osgUtil/Optimizer> 17 17 18 #include <iostream> 18 19 19 20 int main( int argc, char **argv ) … … 21 22 // use an ArgumentParser object to manage the program arguments. 22 23 osg::ArgumentParser arguments(&argc,argv); 23 24 // set up the usage document, in case we need to print out how to use this program.25 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates a simple use of multi-texturing.");26 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");27 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");28 24 29 25 // construct the viewer. 30 osgProducer::Viewer viewer(arguments); 31 32 // set up the value with sensible default event handlers. 33 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 34 35 // get details on keyboard and mouse bindings used by the viewer. 36 viewer.getUsage(*arguments.getApplicationUsage()); 37 38 // if user request help write it out to cout. 39 if (arguments.read("-h") || arguments.read("--help")) 40 { 41 arguments.getApplicationUsage()->write(std::cout); 42 return 1; 43 } 44 45 // any option left unread are converted into errors to write out later. 46 arguments.reportRemainingOptionsAsUnrecognized(); 47 48 // report any errors if they have occured when parsing the program aguments. 49 if (arguments.errors()) 50 { 51 arguments.writeErrorMessages(std::cout); 52 return 1; 53 } 54 55 if (arguments.argc()<=1) 56 { 57 arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 58 return 1; 59 } 26 osgViewer::Viewer viewer; 60 27 61 28 // load the nodes from the commandline arguments. … … 63 30 if (!rootnode) 64 31 { 65 // write_usage(osg::notify(osg::NOTICE),argv[0]);32 osg::notify(osg::NOTICE)<<"Please specify and model filename on the command line."<<std::endl; 66 33 return 1; 67 34 } … … 103 70 104 71 for(unsigned int contextID = 0; 105 contextID< viewer.getDisplaySettings()->getMaxNumberOfGraphicsContexts();72 contextID<osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(); 106 73 ++contextID) 107 74 { … … 117 84 } 118 85 119 while( !viewer.done() ) 120 { 121 // wait for all cull and draw threads to complete. 122 viewer.sync(); 123 124 // update the scene by traversing it with the the update visitor which will 125 // call all node update callbacks and animations. 126 viewer.update(); 127 128 // fire off the cull and draw traversals of the scene. 129 viewer.frame(); 130 131 } 132 133 // wait for all cull and draw threads to complete. 134 viewer.sync(); 135 136 // run a clean up frame to delete all OpenGL objects. 137 viewer.cleanup_frame(); 138 139 // wait for all the clean up frame to complete. 140 viewer.sync(); 141 142 return 0; 86 return viewer.run(); 143 87 }
