Show
Ignore:
Timestamp:
01/11/07 16:19:59 (8 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/osgtessellate/osgtessellate.cpp

    r5939 r5962  
    2323#include <osgDB/ReadFile> 
    2424#include <osgUtil/Optimizer> 
    25 #include <osgProducer/Viewer> 
     25#include <osgViewer/Viewer> 
    2626#include <osg/Projection> 
    2727#include <osg/MatrixTransform> 
     
    741741int main( int argc, char **argv ) 
    742742{ 
    743  
    744743    // use an ArgumentParser object to manage the program arguments. 
    745744    osg::ArgumentParser arguments(&argc,argv); 
    746      
    747     // set up the usage document, in case we need to print out how to use this program. 
    748     arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); 
    749     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is provides an example of doing tesseleation.."); 
    750     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    751     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    752      
    753745 
    754746    // construct the viewer. 
    755     osgProducer::Viewer viewer(arguments); 
    756  
    757     // set up the value with sensible default event handlers. 
    758     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    759  
    760     // get details on keyboard and mouse bindings used by the viewer. 
    761     viewer.getUsage(*arguments.getApplicationUsage()); 
    762  
    763     // if user request help write it out to cout. 
    764     if (arguments.read("-h") || arguments.read("--help")) 
    765     { 
    766         arguments.getApplicationUsage()->write(std::cout); 
    767         return 1; 
    768     } 
    769  
    770     // report any errors if they have occured when parsing the program aguments. 
    771     if (arguments.errors()) 
    772     { 
    773         arguments.writeErrorMessages(std::cout); 
    774         return 1; 
    775     } 
    776      
    777     osg::Timer timer; 
    778     osg::Timer_t start_tick = timer.tick(); 
     747    osgViewer::Viewer viewer; 
    779748 
    780749    // read the scene from the list of file specified commandline args. 
     
    785754    { 
    786755        loadedModel=makeTessellateExample(); 
     756 
    787757    } else { // if there is a loaded model: 
     758 
    788759        // tessellate by searching for geode called tessellate & tessellate it 
    789760        setTessellateVisitor tsv; 
    790761        loadedModel->accept(tsv); 
     762 
    791763    } 
    792764 
     
    795767    gload->addChild(createHUD()); 
    796768 
    797      
    798     // any option left unread are converted into errors to write out later. 
    799     arguments.reportRemainingOptionsAsUnrecognized(); 
    800  
    801     // report any errors if they have occured when parsing the program aguments. 
    802     if (arguments.errors()) 
    803     { 
    804         arguments.writeErrorMessages(std::cout); 
    805     } 
    806  
    807     osg::Timer_t end_tick = timer.tick(); 
    808  
    809     std::cout << "Time to load = "<<timer.delta_s(start_tick,end_tick)<<std::endl; 
    810  
    811769 
    812770    osgUtil::Optimizer optimizer; 
     
    817775 
    818776    // add event handler for keyboard 'n' to retessellate 
    819     viewer.getEventHandlerList().push_front(new KeyboardEventHandler(loadedModel.get())); 
    820  
    821     // create the windows and run the threads. 
    822     viewer.realize(); 
    823  
    824     while( !viewer.done() ) 
    825     { 
    826         // wait for all cull and draw threads to complete. 
    827         viewer.sync(); 
    828  
    829         // update the scene by traversing it with the the update visitor which will 
    830         // call all node update callbacks and animations. 
    831         viewer.update(); 
    832           
    833         // fire off the cull and draw traversals of the scene. 
    834         viewer.frame(); 
    835          
    836     } 
    837      
    838     // wait for all cull and draw threads to complete. 
    839     viewer.sync(); 
    840  
    841     // do OpenGL clean up 
    842     viewer.cleanup_frame(); 
    843  
    844     // wait for all cull and draw threads to complete before exit. 
    845     viewer.sync(); 
    846  
    847     return 0; 
     777    viewer.addEventHandler(new KeyboardEventHandler(loadedModel.get())); 
     778 
     779    return viewer.run(); 
    848780} 
    849781