Show
Ignore:
Timestamp:
01/06/07 22:35:57 (8 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/osgdistortion/osgdistortion.cpp

    r5757 r5923  
    2121#include <osgDB/ReadFile> 
    2222 
    23 #include <osgProducer/Viewer> 
     23#include <osgViewer/Viewer> 
    2424 
    2525using namespace osg; 
     
    171171 
    172172 
    173 int main( int argc, char **argv ) 
     173int main(int argc, char** argv) 
    174174{ 
    175175    // use an ArgumentParser object to manage the program arguments. 
    176176    osg::ArgumentParser arguments(&argc,argv); 
    177177 
    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 pre rendering of scene to a texture, and then apply this texture to geometry."); 
    180     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    181     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    182     
    183178    // construct the viewer. 
    184     osgProducer::Viewer viewer(arguments); 
    185  
    186     // set up the value with sensible default event handlers. 
    187     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    188  
    189     // get details on keyboard and mouse bindings used by the viewer. 
    190     viewer.getUsage(*arguments.getApplicationUsage()); 
    191  
    192     // if user request help write it out to cout. 
    193     if (arguments.read("-h") || arguments.read("--help")) 
    194     { 
    195         arguments.getApplicationUsage()->write(std::cout); 
    196         return 1; 
    197     } 
    198  
    199     // any option left unread are converted into errors to write out later. 
    200     arguments.reportRemainingOptionsAsUnrecognized(); 
    201  
    202     // report any errors if they have occured when parsing the program aguments. 
    203     if (arguments.errors()) 
    204     { 
    205         arguments.writeErrorMessages(std::cout); 
    206         return 1; 
    207     } 
    208      
    209     if (arguments.argc()<=1) 
    210     { 
    211         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    212         return 1; 
    213     } 
    214  
     179    osgViewer::Viewer viewer; 
    215180     
    216181    // load the nodes from the commandline arguments. 
     
    218183    if (!loadedModel) 
    219184    { 
    220 //        write_usage(osg::notify(osg::NOTICE),argv[0]); 
     185        osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl; 
    221186        return 1; 
    222187    } 
    223188     
    224     osg::Node* distortionNode = createDistortionSubgraph(loadedModel, viewer.getClearColor()); 
     189    osg::Node* distortionNode = createDistortionSubgraph(loadedModel, viewer.getCamera()->getClearColor()); 
    225190     
    226191    // add model to the viewer. 
    227192    viewer.setSceneData( distortionNode ); 
    228193 
    229     // create the windows and run the threads. 
    230     viewer.realize(); 
    231  
    232     while( !viewer.done() ) 
    233     { 
    234         // wait for all cull and draw threads to complete. 
    235         viewer.sync(); 
    236  
    237         // update the scene by traversing it with the the update visitor which will 
    238         // call all node update callbacks and animations. 
    239         viewer.update(); 
    240           
    241         // fire off the cull and draw traversals of the scene. 
    242         viewer.frame(); 
    243          
    244     } 
    245      
    246     // wait for all cull and draw threads to complete. 
    247     viewer.sync(); 
    248  
    249     // run a clean up frame to delete all OpenGL objects. 
    250     viewer.cleanup_frame(); 
    251  
    252     // wait for all the clean up frame to complete. 
    253     viewer.sync(); 
    254  
    255     return 0; 
     194    return viewer.run(); 
    256195} 
     196;