Show
Ignore:
Timestamp:
01/05/07 16:54:13 (8 years ago)
Author:
robert
Message:

Ported osgbillboard over to osgViewer

Files:
1 modified

Legend:

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

    r5381 r5911  
    1414#include <osgDB/ReadFile> 
    1515 
    16 #include <osgProducer/Viewer> 
    17  
     16#include <osgViewer/Viewer> 
    1817 
    1918// 
     
    162161} 
    163162 
    164 int main( int argc, char **argv ) 
     163int main(int, char**) 
    165164{ 
     165    // construct the viewer 
     166    osgViewer::Viewer viewer; 
     167     
     168    // set the scene to render 
     169    viewer.setSceneData(createModel()); 
    166170 
    167     // use an ArgumentParser object to manage the program arguments. 
    168     osg::ArgumentParser arguments(&argc,argv); 
    169  
    170     // set up the usage document, in case we need to print out how to use this program. 
    171     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use billboard nodes."); 
    172     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    173     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    174     
    175     // initialize the viewer. 
    176     osgProducer::Viewer viewer(arguments); 
    177  
    178     // set up the value with sensible default event handlers. 
    179     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    180  
    181     // get details on keyboard and mouse bindings used by the viewer. 
    182     viewer.getUsage(*arguments.getApplicationUsage()); 
    183  
    184     // if user request help write it out to cout. 
    185     if (arguments.read("-h") || arguments.read("--help")) 
    186     { 
    187         arguments.getApplicationUsage()->write(std::cout); 
    188         return 1; 
    189     } 
    190  
    191     // any option left unread are converted into errors to write out later. 
    192     arguments.reportRemainingOptionsAsUnrecognized(); 
    193  
    194     // report any errors if they have occured when parsing the program aguments. 
    195     if (arguments.errors()) 
    196     { 
    197         arguments.writeErrorMessages(std::cout); 
    198         return 1; 
    199     } 
    200      
    201     // create a model from the images. 
    202     osg::Node* rootNode = createModel(); 
    203  
    204     // set the scene to render 
    205     viewer.setSceneData(rootNode); 
    206  
    207     // create the windows and run the threads. 
    208     viewer.realize(); 
    209  
    210     while( !viewer.done() ) 
    211     { 
    212         // wait for all cull and draw threads to complete. 
    213         viewer.sync(); 
    214  
    215         // update the scene by traversing it with the the update visitor which will 
    216         // call all node update callbacks and animations. 
    217         viewer.update(); 
    218           
    219         // fire off the cull and draw traversals of the scene. 
    220         viewer.frame(); 
    221          
    222     } 
    223      
    224     // wait for all cull and draw threads to complete. 
    225     viewer.sync(); 
    226  
    227     // run a clean up frame to delete all OpenGL objects. 
    228     viewer.cleanup_frame(); 
    229  
    230     // wait for all the clean up frame to complete. 
    231     viewer.sync(); 
    232      
    233     return 0; 
     171    // run the viewers frame loop 
     172    return viewer.run(); 
    234173}