Show
Ignore:
Timestamp:
01/08/07 11:00:16 (7 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/osghud/osghud.cpp

    r5757 r5927  
    1414#include <osgUtil/Optimizer> 
    1515#include <osgDB/ReadFile> 
    16 #include <osgProducer/Viewer> 
     16#include <osgViewer/Viewer> 
    1717 
    1818#include <osg/Material> 
     
    172172int main( int argc, char **argv ) 
    173173{ 
    174  
    175174    // use an ArgumentParser object to manage the program arguments. 
    176175    osg::ArgumentParser arguments(&argc,argv); 
    177176     
    178     // set up the usage document, in case we need to print out how to use this program. 
    179     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates how to do Head Up Displays."); 
    180     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] [filename] ..."); 
    181     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    182      
    183  
    184     // construct the viewer. 
    185     osgProducer::Viewer viewer(arguments); 
    186  
    187     // set up the value with sensible default event handlers. 
    188     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    189  
    190     // get details on keyboard and mouse bindings used by the viewer. 
    191     viewer.getUsage(*arguments.getApplicationUsage()); 
    192  
    193     // if user request help write it out to cout. 
    194     if (arguments.read("-h") || arguments.read("--help")) 
    195     { 
    196         arguments.getApplicationUsage()->write(std::cout); 
    197         return 1; 
    198     } 
    199  
    200     // any option left unread are converted into errors to write out later. 
    201     arguments.reportRemainingOptionsAsUnrecognized(); 
    202  
    203     // report any errors if they have occured when parsing the program aguments. 
    204     if (arguments.errors()) 
    205     { 
    206         arguments.writeErrorMessages(std::cout); 
    207         return 1; 
    208     } 
    209177     
    210178    // read the scene from the list of file specified commandline args. 
     
    217185    group->addChild(createHUD()); 
    218186 
     187    // construct the viewer. 
     188    osgViewer::Viewer viewer; 
     189 
    219190    // set the scene to render 
    220191    viewer.setSceneData(group.get()); 
    221192 
    222     // create the windows and run the threads. 
    223     viewer.realize(); 
    224  
    225     while( !viewer.done() ) 
    226     { 
    227         // wait for all cull and draw threads to complete. 
    228         viewer.sync(); 
    229  
    230         // update the scene by traversing it with the the update visitor which will 
    231         // call all node update callbacks and animations. 
    232         viewer.update(); 
    233           
    234         // fire off the cull and draw traversals of the scene. 
    235         viewer.frame(); 
    236          
    237     } 
    238      
    239     // wait for all cull and draw threads to complete. 
    240     viewer.sync(); 
    241  
    242     // run a clean up frame to delete all OpenGL objects. 
    243     viewer.cleanup_frame(); 
    244  
    245     // wait for all the clean up frame to complete. 
    246     viewer.sync(); 
    247      
    248     return 0; 
     193    return viewer.run(); 
    249194}