Show
Ignore:
Timestamp:
01/06/07 22:35:57 (7 years ago)
Author:
robert
Message:

Ported osgcopy, osgcubemap, osgdelaunay, osgdepthpartion, osgdistortion, osgfadetext, osgforest and osgfxbrowser to osgViewer

Files:
1 modified

Legend:

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

    r5381 r5923  
    1010#include <osgDB/WriteFile> 
    1111 
    12 #include <osgProducer/Viewer> 
     12#include <osgViewer/Viewer> 
    1313 
    1414#include <osgUtil/Optimizer> 
    1515 
    16 using namespace osg; 
     16#include <iostream> 
    1717 
    1818// Customize the CopyOp so that we add our own verbose  
     
    133133    osg::ArgumentParser arguments(&argc,argv); 
    134134 
    135     // set up the usage document, in case we need to print out how to use this program. 
    136     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of deep vs shallow vs custom copying of scene graphs."); 
    137     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    138     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    139     
    140135    // initialize the viewer. 
    141     osgProducer::Viewer viewer(arguments); 
    142  
    143     // if user request help write it out to cout. 
    144     if (arguments.read("-h") || arguments.read("--help")) 
    145     { 
    146         arguments.getApplicationUsage()->write(std::cout); 
    147         return 1; 
    148     } 
    149  
    150     // any option left unread are converted into errors to write out later. 
    151     arguments.reportRemainingOptionsAsUnrecognized(); 
    152  
    153     // report any errors if they have occured when parsing the program aguments. 
    154     if (arguments.errors()) 
    155     { 
    156         arguments.writeErrorMessages(std::cout); 
    157         return 1; 
    158     } 
    159      
    160     if (arguments.argc()<=1) 
    161     { 
    162         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    163         return 1; 
    164     } 
     136    osgViewer::Viewer viewer; 
    165137 
    166138    // load the nodes from the commandline arguments. 
     
    168140    if (!rootnode) 
    169141    { 
     142        osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl; 
    170143        return 1; 
    171144    } 
     
    232205    viewer.setSceneData(rootnode); 
    233206 
    234     // create the windows and run the threads. 
    235     viewer.realize(); 
    236  
    237     while( !viewer.done() ) 
    238     { 
    239         // wait for all cull and draw threads to complete. 
    240         viewer.sync(); 
    241  
    242         // update the scene by traversing it with the the update visitor which will 
    243         // call all node update callbacks and animations. 
    244         viewer.update(); 
    245           
    246         // fire off the cull and draw traversals of the scene. 
    247         viewer.frame(); 
    248          
    249     } 
    250      
    251     // wait for all cull and draw threads to complete. 
    252     viewer.sync(); 
    253  
    254     // run a clean up frame to delete all OpenGL objects. 
    255     viewer.cleanup_frame(); 
    256  
    257     // wait for all the clean up frame to complete. 
    258     viewer.sync(); 
    259  
    260     return 0; 
     207    return viewer.run(); 
    261208}