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

Ported following examples to osgViewer:

osgshaders
osgshaderterrain
osgshadow
osgshadowtexture

Files:
1 modified

Legend:

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

    r5863 r5956  
    2727#include <osgText/Text> 
    2828 
    29 #include <osgProducer/Viewer> 
     29#include <osgViewer/Viewer> 
     30 
     31#include <iostream> 
    3032 
    3133// for the grid data.. 
     
    123125            stateset->setAttribute(program); 
    124126 
    125 #if 0 
     127#if 1 
    126128            // use inline shaders 
    127129             
     
    142144               "    texcoord.y *= terrainScaleDown.y;\n" 
    143145               "\n" 
    144                "    vec4 position;\n"ttm-> 
     146               "    vec4 position;\n" 
    145147               "    position.x = gl_Vertex.x;\n" 
    146148               "    position.y = gl_Vertex.y;\n" 
     
    240242} 
    241243 
     244#if 0 
    242245class TestSupportCallback : public osgProducer::OsgCameraGroup::RealizeCallback 
    243246{ 
     
    278281         
    279282}; 
    280  
    281 int main( int argc, char **argv ) 
     283#endif 
     284 
     285int main(int, char **) 
    282286{ 
    283  
    284     // use an ArgumentParser object to manage the program arguments. 
    285     osg::ArgumentParser arguments(&argc,argv); 
    286  
    287     // set up the usage document, in case we need to print out how to use this program. 
    288     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates the osg::Shape classes."); 
    289     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    290     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    291     arguments.getApplicationUsage()->addCommandLineOption("--trees <number>","Set the number of trees to create"); 
    292     
    293287    // construct the viewer. 
    294     osgProducer::Viewer viewer(arguments); 
    295  
    296     // set up the value with sensible default event handlers. 
    297     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    298      
    299     // get details on keyboard and mouse bindings used by the viewer. 
    300     viewer.getUsage(*arguments.getApplicationUsage()); 
    301  
    302     // if user request help write it out to cout. 
    303     if (arguments.read("-h") || arguments.read("--help")) 
    304     { 
    305         arguments.getApplicationUsage()->write(std::cout); 
    306         return 1; 
    307     } 
    308  
    309     // any option left unread are converted into errors to write out later. 
    310     arguments.reportRemainingOptionsAsUnrecognized(); 
    311  
    312     // report any errors if they have occured when parsing the program aguments. 
    313     if (arguments.errors()) 
    314     { 
    315         arguments.writeErrorMessages(std::cout); 
    316         return 1; 
    317     } 
    318      
     288    osgViewer::Viewer viewer; 
     289 
    319290    osg::Node* node = createScene(); 
    320291 
     
    322293    viewer.setSceneData( node ); 
    323294 
     295#if 0 
    324296    // register a test extension callback to be called when app realizes and gets a valid graphics context 
    325297    osg::ref_ptr<TestSupportCallback> testSupportCallback = new TestSupportCallback(); 
    326298    viewer.setRealizeCallback(testSupportCallback.get()); 
    327  
    328299    // create the windows and run the threads. 
    329300    viewer.realize(); 
     
    336307        exit(1); 
    337308    } 
    338  
    339     while( !viewer.done() ) 
    340     { 
    341         // wait for all cull and draw threads to complete. 
    342         viewer.sync(); 
    343  
    344         // update the scene by traversing it with the the update visitor which will 
    345         // call all node update callbacks and animations. 
    346         viewer.update(); 
    347           
    348         // fire off the cull and draw traversals of the scene. 
    349         viewer.frame(); 
    350          
    351     } 
     309#else 
     310 
     311    osg::notify(osg::NOTICE)<<"osgshaderterrain OpenGL support test not implemented yet"<<std::endl; 
    352312     
    353     // wait for all cull and draw threads to complete. 
    354     viewer.sync(); 
    355  
    356     // run a clean up frame to delete all OpenGL objects. 
    357     viewer.cleanup_frame(); 
    358  
    359     // wait for all the clean up frame to complete. 
    360     viewer.sync(); 
    361  
    362     return 0; 
     313#endif 
     314 
     315 
     316    return viewer.run(); 
    363317}