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

    r5636 r5927  
    77#include <osgDB/ReadFile> 
    88 
    9 #include <osgProducer/Viewer> 
     9#include <osgViewer/Viewer> 
    1010 
    1111#include <osgUtil/Optimizer> 
     12 
     13#include <iostream> 
    1214 
    1315const int _ops_nb=16; 
     
    119121int main( int argc, char **argv ) 
    120122{ 
    121  
    122123    // use an ArgumentParser object to manage the program arguments. 
    123124    osg::ArgumentParser arguments(&argc,argv); 
    124  
    125     // set up the usage document, in case we need to print out how to use this program. 
    126     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates how to use glLogicOp for mixing rendered scene and the frame-buffer."); 
    127     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    128     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    129     
    130     // construct the viewer. 
    131     osgProducer::Viewer viewer(arguments); 
    132125 
    133126    // load the nodes from the commandline arguments. 
     
    135128    if (!loadedModel) 
    136129    { 
     130        osg::notify(osg::NOTICE)<<"Please specify model filename on the command line."<<std::endl; 
    137131        return 1; 
    138132    } 
     
    140134    osg::Group* root = new osg::Group; 
    141135    root->addChild(loadedModel); 
    142      
    143136     
    144137    osg::StateSet*  stateset =  new osg::StateSet; 
     
    153146    loadedModel->setStateSet(stateset); 
    154147 
     148    // construct the viewer. 
     149    osgViewer::Viewer viewer; 
    155150 
    156  
    157  
    158     // set up the value with sensible default event handlers. 
    159     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    160  
    161     viewer.getEventHandlerList().push_front(new TechniqueEventHandler(logicOp)); 
    162  
    163     // get details on keyboard and mouse bindings used by the viewer. 
    164     viewer.getUsage(*arguments.getApplicationUsage()); 
    165  
    166     // if user request help write it out to cout. 
    167     if (arguments.read("-h") || arguments.read("--help")) 
    168     { 
    169         arguments.getApplicationUsage()->write(std::cout); 
    170         return 1; 
    171     } 
    172  
    173     // any option left unread are converted into errors to write out later. 
    174     arguments.reportRemainingOptionsAsUnrecognized(); 
    175  
    176     // report any errors if they have occured when parsing the program aguments. 
    177     if (arguments.errors()) 
    178     { 
    179         arguments.writeErrorMessages(std::cout); 
    180         return 1; 
    181     } 
    182      
    183     if (arguments.argc()<=1) 
    184     { 
    185         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    186         return 1; 
    187     } 
    188  
    189   
     151    viewer.addEventHandler(new TechniqueEventHandler(logicOp)); 
    190152     
    191153    // run optimization over the scene graph 
     
    196158    viewer.setSceneData( root ); 
    197159     
    198     // create the windows and run the threads. 
    199     viewer.realize(); 
    200  
    201     while( !viewer.done() ) 
    202     { 
    203         // wait for all cull and draw threads to complete. 
    204         viewer.sync(); 
    205  
    206         // update the scene by traversing it with the the update visitor which will 
    207         // call all node update callbacks and animations. 
    208         viewer.update(); 
    209           
    210         // fire off the cull and draw traversals of the scene. 
    211         viewer.frame(); 
    212     } 
    213      
    214     // wait for all cull and draw threads to complete. 
    215     viewer.sync(); 
    216  
    217     // run a clean up frame to delete all OpenGL objects. 
    218     viewer.cleanup_frame(); 
    219  
    220     // wait for all the clean up frame to complete. 
    221     viewer.sync(); 
    222  
    223     return 0; 
     160    return viewer.run(); 
    224161}