Show
Ignore:
Timestamp:
04/25/07 17:32:33 (8 years ago)
Author:
robert
Message:

Added --static and --vbo options to allow the user to toggle on/off dynamic updating
of geometry and use of vertex buffer objects.

Files:
1 modified

Legend:

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

    r6108 r6554  
    1414 
    1515#include <osgViewer/Viewer> 
     16#include <osgViewer/StatsHandler> 
    1617 
    1718#include <iostream> 
     
    8889}; 
    8990 
    90 osg::Node* createModel(const std::string& shader, const std::string& textureFileName, const std::string& terrainFileName) 
     91osg::Node* createModel(const std::string& shader, const std::string& textureFileName, const std::string& terrainFileName, bool dynamic, bool vbo) 
    9192{ 
    9293    osg::Geode* geode = new osg::Geode; 
     
    113114 
    114115            osg::Uniform* coeff = new osg::Uniform("coeff",osg::Vec4(1.0,-1.0f,-1.0f,1.0f)); 
    115             coeff->setUpdateCallback(new UniformVarying); 
     116             
    116117            stateset->addUniform(coeff); 
    117             stateset->setDataVariance(osg::Object::DYNAMIC); 
     118 
     119            if (dynamic) 
     120            { 
     121                coeff->setUpdateCallback(new UniformVarying); 
     122                coeff->setDataVariance(osg::Object::DYNAMIC); 
     123                stateset->setDataVariance(osg::Object::DYNAMIC); 
     124            } 
     125             
    118126        } 
    119127        else if (shader=="matrix") 
     
    226234    } 
    227235     
    228     // geom->setUseVertexBufferObjects(true); 
     236    geom->setUseVertexBufferObjects(vbo); 
    229237 
    230238    return geode; 
     
    244252    osgViewer::Viewer viewer; 
    245253 
     254    // add the stats handler 
     255    viewer.addEventHandler(new osgViewer::StatsHandler); 
     256 
    246257    std::string shader("simple"); 
    247258    while(arguments.read("-s",shader)) {} 
     
    253264    while(arguments.read("-d",terrainFileName)) {} 
    254265 
     266    bool dynamic = true; 
     267    while(arguments.read("--static")) { dynamic = false; } 
     268 
     269    bool vbo = false; 
     270    while(arguments.read("--vbo")) { vbo = true; } 
     271 
    255272    // if user request help write it out to cout. 
    256273    if (arguments.read("-h") || arguments.read("--help")) 
     
    259276        return 1; 
    260277    } 
    261  
     278     
    262279    // load the nodes from the commandline arguments. 
    263     osg::Node* model = createModel(shader,textureFileName,terrainFileName); 
     280    osg::Node* model = createModel(shader,textureFileName,terrainFileName, dynamic, vbo); 
    264281    if (!model) 
    265282    {