Changeset 10831 for OpenSceneGraph/trunk/examples/osgcamera/osgcamera.cpp
- Timestamp:
- 11/25/09 17:31:14 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgcamera/osgcamera.cpp
r10830 r10831 174 174 } 175 175 176 class EnableVBOVisitor : public osg::NodeVisitor 177 { 178 public: 179 EnableVBOVisitor(): 180 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} 181 182 void apply(osg::Geode& geode) 183 { 184 for(unsigned int i=0; i<geode.getNumDrawables();++i) 185 { 186 osg::Geometry* geom = geode.getDrawable(i)->asGeometry(); 187 osg::notify(osg::NOTICE)<<"Enabling VBO"<<std::endl; 188 geom->setUseVertexBufferObjects(true); 189 } 190 } 191 }; 192 176 193 int main( int argc, char **argv ) 177 194 { … … 188 205 if (arguments.read("--repeat",numRepeats) || arguments.read("-r",numRepeats) || arguments.read("--repeat") || arguments.read("-r")) 189 206 { 207 190 208 bool sharedModel = arguments.read("--shared"); 209 bool enableVBO = arguments.read("--vbo"); 210 191 211 osg::ref_ptr<osg::Node> model; 192 if (sharedModel) model = osgDB::readNodeFiles(arguments); 212 if (sharedModel) 213 { 214 model = osgDB::readNodeFiles(arguments); 215 if (!model) return 0; 216 217 if (enableVBO) 218 { 219 EnableVBOVisitor enableVBOs; 220 model->accept(enableVBOs); 221 } 222 } 193 223 194 224 osgViewer::Viewer::ThreadingModel threadingModel = osgViewer::Viewer::AutomaticSelection; … … 207 237 208 238 if (sharedModel) viewer.setSceneData(model.get()); 209 else viewer.setSceneData(osgDB::readNodeFiles(arguments)); 239 else 240 { 241 osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(arguments); 242 if (!node) return 0; 243 244 if (enableVBO) 245 { 246 EnableVBOVisitor enableVBOs; 247 node->accept(enableVBOs); 248 } 249 250 viewer.setSceneData(node.get()); 251 } 210 252 211 253 viewer.run();
