Changeset 5923 for OpenSceneGraph/trunk/examples/osgcubemap/osgcubemap.cpp
- Timestamp:
- 01/06/07 22:35:57 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgcubemap/osgcubemap.cpp
r5381 r5923 17 17 #include <osgGA/DriveManipulator> 18 18 19 #include <osg Producer/Viewer>19 #include <osgViewer/Viewer> 20 20 21 21 #include <iostream> … … 74 74 osg::ArgumentParser arguments(&argc,argv); 75 75 76 // set up the usage document, in case we need to print out how to use this program.77 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use texture cube mapping.");78 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");79 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");80 81 76 // construct the viewer. 82 osgProducer::Viewer viewer(arguments); 83 84 // set up the value with sensible default event handlers. 85 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 86 87 // get details on keyboard and mouse bindings used by the viewer. 88 viewer.getUsage(*arguments.getApplicationUsage()); 89 90 // if user request help write it out to cout. 91 if (arguments.read("-h") || arguments.read("--help")) 92 { 93 arguments.getApplicationUsage()->write(std::cout); 94 return 1; 95 } 96 97 // any option left unread are converted into errors to write out later. 98 arguments.reportRemainingOptionsAsUnrecognized(); 99 100 // report any errors if they have occured when parsing the program aguments. 101 if (arguments.errors()) 102 { 103 arguments.writeErrorMessages(std::cout); 104 return 1; 105 } 77 osgViewer::Viewer viewer; 106 78 107 if (arguments.argc()<=1)108 {109 arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);110 return 1;111 }112 113 79 // load the nodes from the commandline arguments. 114 80 osg::Node* rootnode = osgDB::readNodeFiles(arguments); 115 81 if (!rootnode) { 82 osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl; 116 83 return 1; 117 84 } … … 130 97 viewer.realize(); 131 98 132 133 99 // now check to see if texture cube map is supported. 134 100 for(unsigned int contextID = 0; 135 contextID< viewer.getDisplaySettings()->getMaxNumberOfGraphicsContexts();101 contextID<osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(); 136 102 ++contextID) 137 103 { … … 147 113 } 148 114 149 while( !viewer.done() ) 150 { 151 // wait for all cull and draw threads to complete. 152 viewer.sync(); 153 154 // update the scene by traversing it with the the update visitor which will 155 // call all node update callbacks and animations. 156 viewer.update(); 157 158 // fire off the cull and draw traversals of the scene. 159 viewer.frame(); 160 161 } 162 163 // wait for all cull and draw threads to complete. 164 viewer.sync(); 165 166 // run a clean up frame to delete all OpenGL objects. 167 viewer.cleanup_frame(); 168 169 // wait for all the clean up frame to complete. 170 viewer.sync(); 171 172 return 0; 115 return viewer.run(); 173 116 }
