Show
Ignore:
Timestamp:
01/08/07 11:00:16 (8 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osggeodemo
osggeometry
osghud
osgimpostor
osgkeyboard
osglauncher
osglight
osglightpoint
osglogicop
osglogo
osgmovie
osgmultiplecameras
osgmultitexture
osgoccluder
osgparametric
osgparticle

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osglight/osglight.cpp

    r5381 r5927  
    1 #include <osgProducer/Viewer> 
     1#include <osgViewer/Viewer> 
    22 
    33#include <osg/Group> 
     
    303303    osg::ArgumentParser arguments(&argc,argv); 
    304304 
    305     // set up the usage document, in case we need to print out how to use this program. 
    306     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of OpenGL vertex lighting."); 
    307     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    308     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    309  
    310305    // construct the viewer. 
    311     osgProducer::Viewer viewer(arguments); 
    312  
    313     // set up the value with sensible default event handlers. 
    314     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    315  
    316     // get details on keyboard and mouse bindings used by the viewer. 
    317     viewer.getUsage(*arguments.getApplicationUsage()); 
    318  
    319     // if user request help write it out to cout. 
    320     if (arguments.read("-h") || arguments.read("--help")) 
    321     { 
    322         arguments.getApplicationUsage()->write(std::cout); 
    323         return 1; 
    324     } 
    325  
    326     // any option left unread are converted into errors to write out later. 
    327     arguments.reportRemainingOptionsAsUnrecognized(); 
    328  
    329     // report any errors if they have occured when parsing the program aguments. 
    330     if (arguments.errors()) 
    331     { 
    332         arguments.writeErrorMessages(std::cout); 
    333         return 1; 
    334     } 
     306    osgViewer::Viewer viewer; 
    335307 
    336308    // load the nodes from the commandline arguments. 
     
    351323    viewer.realize(); 
    352324 
    353     // set all the sceneview's up so that their left and right add cull masks are set up. 
    354     for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin(); 
    355         itr!=viewer.getSceneHandlerList().end(); 
    356         ++itr) 
    357     { 
    358         // switch off small feature culling to prevent the light points from being culled. 
    359         osgUtil::SceneView* sceneview = (*itr)->getSceneView(); 
    360         sceneview->setCullingMode( sceneview->getCullingMode() & ~osg::CullStack::SMALL_FEATURE_CULLING); 
    361     } 
    362  
    363     while( !viewer.done() ) 
    364     { 
    365         // wait for all cull and draw threads to complete. 
    366         viewer.sync(); 
    367  
    368         // update the scene by traversing it with the the update visitor which will 
    369         // call all node update callbacks and animations. 
    370         viewer.update(); 
    371           
    372         // fire off the cull and draw traversals of the scene. 
    373         viewer.frame(); 
    374          
    375     } 
    376  
    377     // wait for all cull and draw threads to complete. 
    378     viewer.sync(); 
    379  
    380     // run a clean up frame to delete all OpenGL objects. 
    381     viewer.cleanup_frame(); 
    382  
    383     // wait for all the clean up frame to complete. 
    384     viewer.sync(); 
    385  
    386     return 0; 
     325    viewer.getCamera()->setCullingMode( viewer.getCamera()->getCullingMode() & ~osg::CullStack::SMALL_FEATURE_CULLING); 
     326 
     327    return viewer.run(); 
    387328}