Show
Ignore:
Timestamp:
01/10/07 22:05:26 (8 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osgshaders
osgshaderterrain
osgshadow
osgshadowtexture

Files:
1 modified

Legend:

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

    r5381 r5956  
    2525#include <osgDB/ReadFile> 
    2626#include <osgUtil/Optimizer> 
    27 #include <osgProducer/Viewer> 
     27#include <osgViewer/Viewer> 
    2828 
    2929#include "GL2Scene.h" 
     
    6363/////////////////////////////////////////////////////////////////////////// 
    6464 
    65 int main( int argc, char **argv ) 
     65int main(int, char **) 
    6666{ 
    67     // use an ArgumentParser object to manage the program arguments. 
    68     osg::ArgumentParser args(&argc,argv); 
    69      
    70     // set up the usage document 
    71     args.getApplicationUsage()->setApplicationName(args.getApplicationName()); 
    72     args.getApplicationUsage()->setDescription(args.getApplicationName() + 
    73             " demonstrates the OpenGL Shading Language using core OSG"); 
    74     args.getApplicationUsage()->setCommandLineUsage(args.getApplicationName()); 
    75     args.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    76  
    77     args.getApplicationUsage()->addKeyboardMouseBinding( "x", "Reload and recompile shader source files." ); 
    78     args.getApplicationUsage()->addKeyboardMouseBinding( "y", "Toggle shader enable" ); 
    79  
    8067    // construct the viewer. 
    81     osgProducer::Viewer viewer(args); 
    82     viewer.setUpViewer( osgProducer::Viewer::STANDARD_SETTINGS ); 
    83     viewer.getUsage( *args.getApplicationUsage() ); 
    84  
    85     if( args.read("-h") || args.read("--help") ) 
    86     { 
    87         args.getApplicationUsage()->write(std::cout); 
    88         return 1; 
    89     } 
    90  
    91     // any option left unread are converted into errors to write out later. 
    92     args.reportRemainingOptionsAsUnrecognized(); 
    93     if( args.errors() ) 
    94     { 
    95         args.writeErrorMessages(std::cout); 
    96         return 1; 
    97     } 
     68    osgViewer::Viewer viewer; 
    9869 
    9970    // create the scene 
     
    10172 
    10273    viewer.setSceneData( gl2Scene->getRootNode().get() ); 
    103     viewer.getEventHandlerList().push_front( new KeyHandler(gl2Scene) ); 
    104     viewer.realize(); 
    105     while( !viewer.done() ) 
    106     { 
    107         viewer.sync(); 
    108         viewer.update(); 
    109         viewer.frame(); 
    110     } 
    111      
    112     // wait for all cull and draw threads to complete. 
    113     viewer.sync(); 
    11474 
    115     // run a clean up frame to delete all OpenGL objects. 
    116     viewer.cleanup_frame(); 
     75    viewer.addEventHandler( new KeyHandler(gl2Scene) ); 
    11776 
    118     // wait for all the clean up frame to complete. 
    119     viewer.sync(); 
    120     return 0; 
     77    return viewer.run(); 
    12178} 
    12279