Skip to content

Commit

Permalink
Improved the handling of command line parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Jun 14, 2011
1 parent 48accd9 commit 68d06ca
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions examples/osgocclusionquery/osgocclusionquery.cpp
Expand Up @@ -537,10 +537,10 @@ class KeyHandler : public osgGA::GUIEventHandler
}
else if (ea.getKey()=='o')
{
if (osgDB::writeNodeFile( _node, "saved_model.osg" ))
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote scene graph to \"saved_model.osg\"" << std::endl;
if (osgDB::writeNodeFile( _node, "saved_model.osgt" ))
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote scene graph to \"saved_model.osgt\"" << std::endl;
else
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote failed for \"saved_model.osg\"" << std::endl;
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote failed for \"saved_model.osgt\"" << std::endl;
return true;
}
return false;
Expand Down Expand Up @@ -744,29 +744,36 @@ int main(int argc, char** argv)
// add the help handler
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));

bool optimize = arguments.read( "--opt" );

// load the specified model
osg::ref_ptr<osg::Node> root = osgDB::readNodeFiles( arguments );
if (!root)
osg::ref_ptr<osg::Node> root = 0;

if (arguments.argc()>1)
{
std::cout << arguments.getApplicationName() <<": No files specified, or can't load them." << std::endl;
root = createStockScene().get();
if (!root)
root = osgDB::readNodeFiles( arguments );
if (root.valid())
{
std::cout << arguments.getApplicationName() <<": Failed to create stock scene." << std::endl;
// Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph.
OcclusionQueryVisitor oqv;
root->accept( oqv );
}
else
{
std::cout << arguments.getApplicationName() <<": unable to load specified data." << std::endl;
return 1;
}
std::cout << "Using stock scene instead." << std::endl;
}
else
{
// Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph.
OcclusionQueryVisitor oqv;
root->accept( oqv );
root = createStockScene().get();
if (!root)
{
std::cout << arguments.getApplicationName() <<": Failed to create stock scene." << std::endl;
return 1;
}
}

bool optimize = arguments.read( "--opt" );

// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();

Expand Down

0 comments on commit 68d06ca

Please sign in to comment.