Changeset 5927 for OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
- Timestamp:
- 01/08/07 11:00:16 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
r5636 r5927 1 1 // -*-c++-*- 2 2 3 #include <osg Producer/Viewer>3 #include <osgViewer/Viewer> 4 4 5 5 #include <osgDB/ReadFile> … … 19 19 #include <osgGA/EventVisitor> 20 20 21 #include <iostream> 22 21 23 osg::ImageStream* s_imageStream = 0; 22 class PostSwapFinishCallback : public Producer::Camera::Callback23 {24 public:25 26 PostSwapFinishCallback() {}27 28 virtual void operator()(const Producer::Camera& camera)29 {30 // osg::Timer_t start_tick = osg::Timer::instance()->tick();31 32 osgProducer::OsgSceneHandler* sh = const_cast<osgProducer::OsgSceneHandler*>(dynamic_cast<const osgProducer::OsgSceneHandler*>(camera.getSceneHandler()));33 34 if (s_imageStream && s_imageStream->getPixelBufferObject()) s_imageStream->getPixelBufferObject()->compileBuffer(*(sh->getSceneView()->getState()));35 // glFinish();36 37 //osg::notify(osg::NOTICE)<<"callback after PBO "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;38 }39 };40 41 24 class MovieEventHandler : public osgGA::GUIEventHandler 42 25 { … … 134 117 case(osgGA::GUIEventAdapter::RELEASE): 135 118 { 119 #if 0 136 120 osgProducer::Viewer* viewer = dynamic_cast<osgProducer::Viewer*>(&aa); 137 121 osgUtil::IntersectVisitor::HitList hlist; … … 206 190 207 191 } 208 209 192 } 210 193 } … … 213 196 osg::notify(osg::NOTICE)<<"No hit"<<std::endl; 214 197 } 198 #else 199 osg::notify(osg::NOTICE)<<"Need to implement picking."<<std::endl; 200 #endif 215 201 break; 216 202 } … … 331 317 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 332 318 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 319 arguments.getApplicationUsage()->addCommandLineOption("--texture2D","Use Texture2D rather than TextureRectangle."); 320 arguments.getApplicationUsage()->addCommandLineOption("--shader","Use shaders to post process the video."); 333 321 334 322 bool useTextureRectangle = true; … … 336 324 337 325 // construct the viewer. 338 osg Producer::Viewer viewer(arguments);326 osgViewer::Viewer viewer; 339 327 340 328 while (arguments.read("--texture2D")) useTextureRectangle=false; 341 329 while (arguments.read("--shader")) useShader=true; 342 343 // set up the value with sensible default event handlers.344 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);345 346 // get details on keyboard and mouse bindings used by the viewer.347 viewer.getUsage(*arguments.getApplicationUsage());348 330 349 331 // if user request help write it out to cout. … … 423 405 { 424 406 // nothing loaded. 407 arguments.getApplicationUsage()->write(std::cout); 425 408 return 1; 426 409 } 427 428 429 410 430 411 // pass the model to the MovieEventHandler so it can pick out ImageStream's to manipulate. … … 446 427 } 447 428 448 449 // any option left unread are converted into errors to write out later.450 arguments.reportRemainingOptionsAsUnrecognized();451 452 // report any errors if they have occured when parsing the program aguments.453 if (arguments.errors())454 {455 arguments.writeErrorMessages(std::cout);456 }457 /*458 // set up a post swap callback to flush deleted GL objects and compile new GL objects459 for(unsigned int cameraNum=0;cameraNum<viewer.getNumberOfCameras();++cameraNum)460 {461 Producer::Camera* camera=viewer.getCamera(cameraNum);462 camera->addPostSwapCallback(new PostSwapFinishCallback());463 }464 */465 429 // set the scene to render 466 430 viewer.setSceneData(geode.get()); 467 431 468 432 // create the windows and run the threads. 469 viewer.realize(); 470 471 while( !viewer.done() ) 472 { 473 // wait for all cull and draw threads to complete. 474 viewer.sync(); 475 476 // update the scene by traversing it with the the update visitor which will 477 // call all node update callbacks and animations. 478 viewer.update(); 479 480 // fire off the cull and draw traversals of the scene. 481 viewer.frame(); 482 483 } 484 485 // wait for all cull and draw threads to complete. 486 viewer.sync(); 487 488 // run a clean up frame to delete all OpenGL objects. 489 viewer.cleanup_frame(); 490 491 // wait for all the clean up frame to complete. 492 viewer.sync(); 493 494 return 0; 433 return viewer.run(); 495 434 496 435
