Show
Ignore:
Timestamp:
01/11/07 16:19:59 (7 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osgteapot
osgtessellate
osgtext
osgtexture1D
osgtexture2D
osgtexture3D
osgtexturerectangle
osgvertexprogram
osgvolume
osgwindows
osgsimple
osgkeyboardmouse

Files:
1 modified

Legend:

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

    r5381 r5962  
    55#include <osgDB/ReadFile> 
    66 
    7 #include <osgProducer/Viewer> 
     7#include <osgViewer/Viewer> 
    88 
    99 
     
    315315int main( int argc, char **argv ) 
    316316{ 
    317  
    318     // use an ArgumentParser object to manage the program arguments. 
    319     osg::ArgumentParser arguments(&argc,argv); 
    320  
    321     // set up the usage document, in case we need to print out how to use this program. 
    322     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates how to encpsulate OpenGL rendering code via sublcassing of osg::Drawable.."); 
    323     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    324     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    325     
    326317    // construct the viewer. 
    327     osgProducer::Viewer viewer(arguments); 
    328  
    329     // set up the value with sensible default event handlers. 
    330     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    331  
    332     // get details on keyboard and mouse bindings used by the viewer. 
    333     viewer.getUsage(*arguments.getApplicationUsage()); 
    334  
    335     // if user request help write it out to cout. 
    336     if (arguments.read("-h") || arguments.read("--help")) 
    337     { 
    338         arguments.getApplicationUsage()->write(std::cout); 
    339         return 1; 
    340     } 
    341  
    342     // any option left unread are converted into errors to write out later. 
    343     arguments.reportRemainingOptionsAsUnrecognized(); 
    344  
    345     // report any errors if they have occured when parsing the program aguments. 
    346     if (arguments.errors()) 
    347     { 
    348         arguments.writeErrorMessages(std::cout); 
    349         return 1; 
    350     } 
     318    osgViewer::Viewer viewer; 
    351319 
    352320    // add model to viewer. 
     
    354322 
    355323    // create the windows and run the threads. 
    356     viewer.realize(); 
    357  
    358     while( !viewer.done() ) 
    359     { 
    360         // wait for all cull and draw threads to complete. 
    361         viewer.sync(); 
    362  
    363         // update the scene by traversing it with the the update visitor which will 
    364         // call all node update callbacks and animations. 
    365         viewer.update(); 
    366           
    367         // fire off the cull and draw traversals of the scene. 
    368         viewer.frame(); 
    369          
    370     } 
    371      
    372     // wait for all cull and draw threads to complete. 
    373     viewer.sync(); 
    374  
    375     // run a clean up frame to delete all OpenGL objects. 
    376     viewer.cleanup_frame(); 
    377  
    378     // wait for all the clean up frame to complete. 
    379     viewer.sync(); 
    380  
    381     return 0; 
     324    return viewer.run(); 
    382325}