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/osgkeyboard/osgkeyboard.cpp

    r5636 r5927  
    1 #include <osgProducer/Viewer> 
     1#include <osgViewer/Viewer> 
    22#include <osg/io_utils> 
    33 
     
    371371}; 
    372372 
    373 int main( int argc, char **argv ) 
    374 { 
    375  
    376     // use an ArgumentParser object to manage the program arguments. 
    377     osg::ArgumentParser arguments(&argc,argv); 
    378  
    379     // set up the usage document, in case we need to print out how to use this program. 
    380     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of handling keyboard events and text."); 
    381     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    382     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    383     arguments.getApplicationUsage()->addCommandLineOption("-c","Mannually create occluders"); 
    384     
    385     // initialize the viewer. 
    386     osgProducer::Viewer viewer(arguments); 
    387  
    388     // set up the value with sensible default event handlers. 
    389     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    390  
     373int main(int , char **) 
     374{ 
     375    osgViewer::Viewer viewer; 
    391376 
    392377    osg::ref_ptr<KeyboardModel> keyboardModel = new KeyboardModel; 
    393378 
    394     KeyboardEventHandler* keh = new KeyboardEventHandler(keyboardModel.get()); 
    395     viewer.getEventHandlerList().push_front(keh); 
    396  
    397     // get details on keyboard and mouse bindings used by the viewer. 
    398     viewer.getUsage(*arguments.getApplicationUsage()); 
    399  
    400     // if user request help write it out to cout. 
    401     if (arguments.read("-h") || arguments.read("--help")) 
    402     { 
    403         arguments.getApplicationUsage()->write(std::cout); 
    404         return 1; 
    405     } 
    406  
    407     // any option left unread are converted into errors to write out later. 
    408     arguments.reportRemainingOptionsAsUnrecognized(); 
    409  
    410     // report any errors if they have occured when parsing the program aguments. 
    411     if (arguments.errors()) 
    412     { 
    413         arguments.writeErrorMessages(std::cout); 
    414         return 1; 
    415     } 
    416       
    417     // attach the scene graph. 
     379    viewer.addEventHandler(new KeyboardEventHandler(keyboardModel.get())); 
    418380    viewer.setSceneData( keyboardModel->getScene() ); 
    419381 
    420     //osgDB::writeNodeFile(*keyboardModel->getScene(),"test.osg"); 
    421  
    422     // create the windows and run the threads. 
    423     viewer.realize(); 
    424  
    425  
    426     while( !viewer.done() ) 
    427     { 
    428         // wait for all cull and draw threads to complete. 
    429         viewer.sync(); 
    430  
    431         // update the scene by traversing it with the the update visitor which will 
    432         // call all node update callbacks and animations. 
    433         viewer.update(); 
    434           
    435         // fire off the cull and draw traversals of the scene. 
    436         viewer.frame(); 
    437          
    438     } 
    439     
    440     // wait for all cull and draw threads to complete. 
    441     viewer.sync(); 
    442  
    443     // run a clean up frame to delete all OpenGL objects. 
    444     viewer.cleanup_frame(); 
    445  
    446     // wait for all the clean up frame to complete. 
    447     viewer.sync(); 
    448  
    449     return 0; 
    450 } 
     382    return viewer.run(); 
     383}