ArgumentParser参数解析器
使用(Examples osganimate):
判断有没有输入指定的参数
osg::ArgumentParser arguments(&argc,argv);
while (arguments.read("--overlay")) overlay = true;
Examples osgshadow中使用方法
setDescription是描述信息,在命令行下运行程序,会提前打印出来作为提示;
addCommandLineOption是命令行选项信息
arguments.getApplicationUsage()->write()函数的默认的是打出CommandLineOption的信息,可显示在屏幕上或者文本里。
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc, argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " is the example which demonstrates using of GL_ARB_shadow extension implemented in osg::Texture class");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName());
arguments.getApplicationUsage()->addCommandLineOption("-h or --help", "Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--positionalLight", "Use a positional light.");
arguments.getApplicationUsage()->addCommandLineOption("--directionalLight", "Use a direction light.");
arguments.getApplicationUsage()->addCommandLineOption("--noUpdate", "Disable the updating the of light source.");
arguments.getApplicationUsage()->addCommandLineOption("--base", "Add a base geometry to test shadows.");
arguments.getApplicationUsage()->addCommandLineOption("--sv", "Select ShadowVolume implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
// arguments.getApplicationUsage()->addCommandLineOption("--pssm", "Select ParallelSplitShadowMap implementation.");
arguments.getApplicationUsage()->addCommandLineOption("-1", "Use test model one.");
arguments.getApplicationUsage()->addCommandLineOption("-2", "Use test model two.");
arguments.getApplicationUsage()->addCommandLineOption("-3", "Use test model three.");
arguments.getApplicationUsage()->addCommandLineOption("--two-sided", "Use two-sided stencil extension for shadow volumes.");
arguments.getApplicationUsage()->addCommandLineOption("--two-pass", "Use two-pass stencil for shadow volumes.");
// construct the viewer.
osgViewer::Viewer viewer;
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
...{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
当输入参数"-h"后,则出现下面的界面
osg::ArgumentParser和osg::ApplicationUsage 收藏
ArgumentParser参数解析器
使用(Examples osganimate):
判断有没有输入指定的参数
osg::ArgumentParser arguments(&argc,argv);
while (arguments.read("--overlay")) overlay = true;
Examples osgshadow中使用方法
setDescription是描述信息,在命令行下运行程序,会提前打印出来作为提示;
addCommandLineOption是命令行选项信息
arguments.getApplicationUsage()->write()函数的默认的是打出CommandLineOption的信息,可显示在屏幕上或者文本里。
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc, argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " is the example which demonstrates using of GL_ARB_shadow extension implemented in osg::Texture class");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName());
arguments.getApplicationUsage()->addCommandLineOption("-h or --help", "Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--positionalLight", "Use a positional light.");
arguments.getApplicationUsage()->addCommandLineOption("--directionalLight", "Use a direction light.");
arguments.getApplicationUsage()->addCommandLineOption("--noUpdate", "Disable the updating the of light source.");
arguments.getApplicationUsage()->addCommandLineOption("--base", "Add a base geometry to test shadows.");
arguments.getApplicationUsage()->addCommandLineOption("--sv", "Select ShadowVolume implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
// arguments.getApplicationUsage()->addCommandLineOption("--pssm", "Select ParallelSplitShadowMap implementation.");
arguments.getApplicationUsage()->addCommandLineOption("-1", "Use test model one.");
arguments.getApplicationUsage()->addCommandLineOption("-2", "Use test model two.");
arguments.getApplicationUsage()->addCommandLineOption("-3", "Use test model three.");
arguments.getApplicationUsage()->addCommandLineOption("--two-sided", "Use two-sided stencil extension for shadow volumes.");
arguments.getApplicationUsage()->addCommandLineOption("--two-pass", "Use two-pass stencil for shadow volumes.");
// construct the viewer.
osgViewer::Viewer viewer;
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
...{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
当输入参数"-h"后,则出现下面的界面
osgblendequation
读取所有参数的文件的办法:
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/zhuqinglu/archive/2007/09/10/1779600.aspx