Show
Ignore:
Timestamp:
01/05/07 17:00:28 (7 years ago)
Author:
robert
Message:

Ported osgblendequation across to osgViewer

Files:
1 modified

Legend:

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

    r5636 r5912  
    77#include <osgDB/ReadFile> 
    88 
    9 #include <osgProducer/Viewer> 
     9#include <osgUtil/Optimizer> 
    1010 
    11 #include <osgUtil/Optimizer> 
     11#include <osgViewer/Viewer> 
     12 
     13#include <iostream> 
    1214 
    1315const int _eq_nb=8; 
     
    117119    
    118120    // construct the viewer. 
    119     osgProducer::Viewer viewer(arguments); 
     121    osgViewer::Viewer viewer; 
    120122 
    121123    // load the nodes from the commandline arguments. 
     
    137139             
    138140    //tell to sort the mesh before displaying it 
    139     stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); 
    140              
     141    stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);            
    141142 
    142143    loadedModel->setStateSet(stateset); 
    143144 
     145    viewer.addEventHandler(new TechniqueEventHandler(blendEquation)); 
    144146 
    145  
    146  
    147     // set up the value with sensible default event handlers. 
    148     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    149  
    150     viewer.getEventHandlerList().push_front(new TechniqueEventHandler(blendEquation)); 
    151  
    152     // get details on keyboard and mouse bindings used by the viewer. 
    153     viewer.getUsage(*arguments.getApplicationUsage()); 
    154  
    155     // if user request help write it out to cout. 
    156     if (arguments.read("-h") || arguments.read("--help")) 
    157     { 
    158         arguments.getApplicationUsage()->write(std::cout); 
    159         return 1; 
    160     } 
    161  
    162     // any option left unread are converted into errors to write out later. 
    163     arguments.reportRemainingOptionsAsUnrecognized(); 
    164  
    165     // report any errors if they have occured when parsing the program aguments. 
    166     if (arguments.errors()) 
    167     { 
    168         arguments.writeErrorMessages(std::cout); 
    169         return 1; 
    170     } 
    171      
    172     if (arguments.argc()<=1) 
    173     { 
    174         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    175         return 1; 
    176     } 
    177  
    178   
    179147     
    180148    // run optimization over the scene graph 
     
    185153    viewer.setSceneData( root ); 
    186154     
    187     // create the windows and run the threads. 
    188     viewer.realize(); 
    189  
    190     while( !viewer.done() ) 
    191     { 
    192         // wait for all cull and draw threads to complete. 
    193         viewer.sync(); 
    194  
    195         // update the scene by traversing it with the the update visitor which will 
    196         // call all node update callbacks and animations. 
    197         viewer.update(); 
    198           
    199         // fire off the cull and draw traversals of the scene. 
    200         viewer.frame(); 
    201          
    202     } 
    203      
    204     // wait for all cull and draw threads to complete. 
    205     viewer.sync(); 
    206  
    207     // run a clean up frame to delete all OpenGL objects. 
    208     viewer.cleanup_frame(); 
    209  
    210     // wait for all the clean up frame to complete. 
    211     viewer.sync(); 
    212  
    213     return 0; 
     155    return viewer.run(); 
    214156}