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

    r5381 r5962  
    2424#include <osgUtil/Optimizer> 
    2525 
    26 #include <osgProducer/Viewer> 
     26#include <osgViewer/Viewer> 
     27 
     28#include <iostream> 
    2729 
    2830 
     
    345347    osg::ArgumentParser arguments(&argc,argv); 
    346348 
    347     // set up the usage document, in case we need to print out how to use this program. 
    348     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrate support for ARB_vertex_program."); 
    349     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    350     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    351     
    352349    // construct the viewer. 
    353     osgProducer::Viewer viewer(arguments); 
    354  
    355     // set up the value with sensible default event handlers. 
    356     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    357  
    358     // get details on keyboard and mouse bindings used by the viewer. 
    359     viewer.getUsage(*arguments.getApplicationUsage()); 
    360  
    361     // if user request help write it out to cout. 
    362     if (arguments.read("-h") || arguments.read("--help")) 
    363     { 
    364         arguments.getApplicationUsage()->write(std::cout); 
    365         return 1; 
    366     } 
    367  
    368     // any option left unread are converted into errors to write out later. 
    369     arguments.reportRemainingOptionsAsUnrecognized(); 
    370  
    371     // report any errors if they have occured when parsing the program aguments. 
    372     if (arguments.errors()) 
    373     { 
    374         arguments.writeErrorMessages(std::cout); 
    375         return 1; 
    376     } 
     350    osgViewer::Viewer viewer; 
    377351 
    378352    osg::Group* rootnode = new osg::Group; 
     
    407381 
    408382    // now check to see if vertex program is supported. 
    409     for(unsigned int contextID = 0;  
    410         contextID<viewer.getDisplaySettings()->getMaxNumberOfGraphicsContexts(); 
    411         ++contextID) 
    412     { 
     383    osgViewer::Viewer::Windows windows; 
     384    viewer.getWindows(windows); 
     385    for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); 
     386        itr != windows.end(); 
     387        ++itr) 
     388    { 
     389        unsigned int contextID = (*itr)->getState()->getContextID(); 
    413390        osg::VertexProgram::Extensions* vpExt = osg::VertexProgram::getExtensions(contextID,false); 
    414391        if (vpExt) 
     
    422399    } 
    423400 
    424     while( !viewer.done() ) 
    425     { 
    426         // wait for all cull and draw threads to complete. 
    427         viewer.sync(); 
    428  
    429         // update the scene by traversing it with the the update visitor which will 
    430         // call all node update callbacks and animations. 
    431         viewer.update(); 
    432           
    433         // fire off the cull and draw traversals of the scene. 
    434         viewer.frame(); 
    435          
    436     } 
    437      
    438     // wait for all cull and draw threads to complete. 
    439     viewer.sync(); 
    440  
    441     // run a clean up frame to delete all OpenGL objects. 
    442     viewer.cleanup_frame(); 
    443  
    444     // wait for all the clean up frame to complete. 
    445     viewer.sync(); 
    446  
    447     return 0; 
     401    return viewer.run(); 
    448402}