Ported all glut based demos across to using the new osg::ArgumentParser.

This commit is contained in:
Robert Osfield 2003-03-14 10:49:06 +00:00
parent 34fc7dd289
commit 2ca505b3d8
43 changed files with 873 additions and 1373 deletions

View File

@ -111,7 +111,6 @@ DEMOS_DIRS = \
osggeometry\
osghangglide\
osghud\
osgtext\
osgimpostor\
osglight\
osglightpoint\
@ -120,13 +119,14 @@ DEMOS_DIRS = \
osgoccluder\
osgparticle\
osgprerender\
osgshadowtexture\
osgreflect\
osgscribe\
osgsequence\
osgshadowtexture\
osgshape\
osgstereoimage\
osgteapot\
osgtext\
osgtexture1D\
osgtexture2D\
osgtexture3D\

View File

@ -3,6 +3,12 @@
OSG News (most significant items from ChangeLog)
================================================
Improvemnts to the Makefle system.
Added support for early abort of rendering, useful for interactive
applications which occasional have rendering that takes that long
enough (i.e. several second) that end users may wish to abort
during the drawing.
Improved thread safety when working multipipe systems.
@ -10,7 +16,7 @@ OSG News (most significant items from ChangeLog)
New MD2 plugin
New osgText implementions.
New thread safe osgText implemention.
24th January 2003 - OpenSceneGraph-0.9.3.tar.gz

View File

@ -42,11 +42,11 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
readEnvironmentalVariables();
}
DisplaySettings(std::vector<std::string>& commandLine)
DisplaySettings(ArgumentParser& arguments)
{
setDefaults();
readEnvironmentalVariables();
readCommandLine(commandLine);
readCommandLine(arguments);
}
DisplaySettings(const DisplaySettings& vs);
@ -61,12 +61,8 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
void readEnvironmentalVariables();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(std::vector<std::string>& commandLine);
/** read the commandline arguments.*/
void readCommandLine(ArgumentParser& parser);
void readCommandLine(ArgumentParser& arguments);
void setStereo(bool on) { _stereo = on; }

View File

@ -51,9 +51,6 @@ class OSGDB_EXPORT Registry : public osg::Referenced
static Registry* instance();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(std::vector<std::string>& commandLine);
/** read the command line arguments.*/
void readCommandLine(osg::ArgumentParser& commandLine);
@ -201,12 +198,6 @@ class OSGDB_EXPORT Registry : public osg::Referenced
};
/** read the command line string list into the osgDB::Registry(), removing any matched control sequences.*/
inline void readCommandLine(std::vector<std::string>& commandLine)
{
Registry::instance()->readCommandLine(commandLine);
}
/** read the command line arguments.*/
inline void readCommandLine(osg::ArgumentParser& parser)
{

View File

@ -19,6 +19,7 @@
#include <osg/Geode>
#include <osg/Timer>
#include <osg/DisplaySettings>
#include <osg/ArgumentParser>
#include <osgGA/GUIEventAdapter>
#include <osgGA/CameraManipulator>
@ -46,8 +47,13 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
public:
Viewer();
Viewer(osg::ArgumentParser& arguments);
virtual ~Viewer();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(osg::ArgumentParser& arguments);
/** init is deprecated, you should use addViewport instead. init is
* only available for backwards compatibility.*/
virtual void init(osg::Node* rootnode);
@ -108,8 +114,6 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
/// Toggle fullscreen
virtual void toggleFullScreen();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(std::vector<std::string>& commandLine);
void setDisplaySettings(osg::DisplaySettings* ds) { _displaySettings = ds; }
osg::DisplaySettings* getDisplaySettings() { return _displaySettings.get(); }
@ -129,6 +133,8 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
int mapWindowXYToViewport(int x, int y);
protected:
void initialize();
virtual void clear();

View File

@ -12,8 +12,6 @@
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
@ -190,26 +188,32 @@ osg::Node* createModel()
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* model = createModel();

View File

@ -165,25 +165,32 @@ osg::Node* createModel()
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// create a model from the images.
osg::Node* rootNode = createModel();

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/Transform>
@ -15,39 +13,8 @@
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
class UpdateCallback : public osg::NodeCallback
{
@ -161,35 +128,35 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
// write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -17,7 +17,6 @@
#include <osgGA/DriveManipulator>
#include <osgUtil/TransformCallback>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osgUtil/Optimizer>
@ -128,34 +127,35 @@ osg::Node* decorate_with_clip_node(osg::Node* subgraph)
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -18,40 +18,8 @@
#include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
using namespace osg;
// Customize the CopyOp so that we add our own verbose
// output of what's being copied.
class MyCopyOp : public osg::CopyOp
@ -166,38 +134,37 @@ class MyCopyOp : public osg::CopyOp
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 1;
}

View File

@ -7,7 +7,6 @@
#include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osg/Math>
@ -160,23 +159,33 @@ osg::Geode* createGeometryCube()
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
glutInit( &argc, argv );
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the viewer and the model to it.
osgGLUT::Viewer viewer;
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
osg::MatrixTransform* myTransform = new osg::MatrixTransform();
myTransform->addChild( createGeometryCube() );

View File

@ -17,44 +17,11 @@
#include <osgGA/DriveManipulator>
#include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <iostream>
#include <string>
#include <vector>
void write_usage(std::ostream& out, const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out <<" -f - start with a full screen, borderless window." << std::endl;
out << std::endl;
}
void create_specular_highlights(osg::Node *node)
{
osg::StateSet *ss = node->getOrCreateStateSet();
@ -103,32 +70,35 @@ void create_specular_highlights(osg::Node *node)
int main(int argc, char *argv[])
{
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2) {
write_usage(std::cout, argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1; i<argc; ++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) {
return 1;
}

View File

@ -26,41 +26,6 @@
// geo loader and having direct links with it.
#include "../../osgPlugins/geo/osgGeoAnimation.h"
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out <<" -f - start with a full screen, borderless window." << std::endl;
out <<" -p pathfile - Use the AnimationPathManipulator (key binding '4') and use\n"
" pathfile to define the animation path. pathfile is an ascii\n"
" file containing lines of eight floating point numbers representing\n"
" time, position (x,y,z) and attitude (x,y,z,w as a quaternion)." << std::endl;
out << std::endl;
}
//== event trapper gets events
@ -122,63 +87,46 @@ double dodynamics(const double time, const double val, const std::string name)
int main( int argc, char **argv )
{
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Use specificed animation path file for camera animation");
// read the commandline args.
std::string pathfile;
while (arguments.read("-p",pathfile)) {}
float camera_fov=-1;
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) {
if( std::string(argv[i]) == "-p" ) {
if( (i+1) >= argc ) {
write_usage( std::cout, argv[0]);
return 1;
}
else
pathfile = std::string(argv[++i]);
} else if( std::string(argv[i]) == "-fov" ) {
camera_fov=atof(argv[i+1]);
++i; // skip the value
}
else
commandLine.push_back(argv[i]);
}
while (arguments.read("-fov",camera_fov)) {}
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// get the path of the executable and use it to set internal data and library paths.
std::string executablePath = osgDB::getFilePath(argv[0]);
if (!executablePath.empty())
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
osg::notify(osg::NOTICE) << "Adding executable path '"<<executablePath<<"' to OpenSceneGraph data and library file paths."<<std::endl;
osgDB::getDataFilePathList().push_front(executablePath);
osgDB::getLibraryFilePathList().push_front(executablePath);
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 1;
}

View File

@ -13,7 +13,6 @@
#include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osg/Math>
@ -643,20 +642,32 @@ osg::Node* createBackground()
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
glutInit( &argc, argv );
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the viewer and the model to it.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// create the model

View File

@ -12,7 +12,6 @@
#include <osgGA/AnimationPathManipulator>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include "GliderManipulator.h"
@ -104,26 +103,36 @@ osg::Group* createModel()
int main( int argc, char **argv )
{
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) rootnode = createModel();
viewer.addViewport( rootnode );

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/MatrixTransform>
@ -24,37 +22,6 @@
#include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
osg::Node* createHUD()
{
osg::Geode* geode = new osg::Geode();
@ -159,35 +126,36 @@ struct MyCallback : public osg::NodeCallback
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
// write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -225,11 +225,11 @@ int main( int argc, char **argv )
viewer.setWindowTitle(argv[0]);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
std::vector<std::string> arguments;
for(int i=1;i<argc;++i) arguments.push_back(argv[i]);
// load the nodes from the commandline arguments.
osg::Node* model = osgDB::readNodeFiles(commandLine);
osg::Node* model = osgDB::readNodeFiles(arguments);
if (model)
{
// the osgUtil::InsertImpostorsVisitor used lower down to insert impostors

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/Group>
@ -301,29 +299,36 @@ osg::Node* createRoom(osg::Node* loadedModel)
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
// create a room made of foor walls, a floor, a roof, and swinging light fitting.
osg::Node* rootnode = createRoom(loadedModel);

View File

@ -20,37 +20,6 @@
#include <osgSim/LightPointNode>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
#define INTERPOLATE(member) lp.member = start.member*rstart + end.member*rend;
void addToLightPointNode(osgSim::LightPointNode& lpn,osgSim::LightPoint& start,osgSim::LightPoint& end,unsigned int noSteps)
@ -149,30 +118,38 @@ osg::Node* createLightPointsDatabase()
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
osg::Group* rootnode = new osg::Group;
// load the nodes from the commandline arguments.
rootnode->addChild(osgDB::readNodeFiles(commandLine));
rootnode->addChild(osgDB::readNodeFiles(arguments));
rootnode->addChild(createLightPointsDatabase());
if (!rootnode)
{

View File

@ -17,7 +17,6 @@
#include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osgDB/ReadFile>
@ -404,24 +403,35 @@ osg::Node* createLogo()
int main( int argc, char **argv )
{
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("ps","Render the Professional Services logo");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the viewer and the model to it.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
if (arguments.find("ps")) s_ProfessionalServices = true;
if (std::find(commandLine.begin(),commandLine.end(),std::string("ps"))!=commandLine.end()) s_ProfessionalServices = true;
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
osg::Node* node = createLogo();

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/Notify>
@ -15,72 +13,40 @@
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
// write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/MatrixTransform>
@ -23,45 +21,6 @@
#include <osg/OccluderNode>
#include <osg/Geometry>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -c - set osgoccluder's manual mode for creating occluders."<< std::endl;
out <<" press 'a' to start/add points to an occluder, using "<< std::endl;
out <<" the nearest vertex to the current mouse poistion."<< std::endl;
out <<" press 'e' to end occluder, this occluder is then added"<< std::endl;
out <<" into the model."<< std::endl;
out <<" press 'O' save just the occluders to disk. "<< std::endl;
out << std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
class OccluderEventHandler : public osgGA::GUIEventHandler
{
@ -320,42 +279,39 @@ osg::Group* createOccludersAroundModel(osg::Node* model)
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
bool manuallyCreateImpostors = false;
std::vector<std::string>::iterator itr=std::find(commandLine.begin(),commandLine.end(),std::string("-c"));
if (itr!=commandLine.end())
{
manuallyCreateImpostors = true;
commandLine.erase(itr);
}
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-c","Mannually create occluders");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
bool manuallyCreateOccluders = false;
while (arguments.read("-c")) { manuallyCreateOccluders = true; }
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* loadedmodel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedmodel = osgDB::readNodeFiles(arguments);
if (!loadedmodel)
{
// write_usage(osg::notify(osg::NOTICE),argv[0]);
@ -369,7 +325,7 @@ int main( int argc, char **argv )
// add the occluders to the loaded model.
osg::Group* rootnode = NULL;
if (manuallyCreateImpostors)
if (manuallyCreateOccluders)
{
rootnode = new osg::Group;
rootnode->addChild(loadedmodel);
@ -388,7 +344,7 @@ int main( int argc, char **argv )
viewer.registerCameraManipulator(new osgGA::FlightManipulator);
viewer.registerCameraManipulator(new osgGA::DriveManipulator);
if (manuallyCreateImpostors)
if (manuallyCreateOccluders)
{
viewer.prependEventHandler(new OccluderEventHandler(viewer.getViewportSceneView(0),rootnode));
}

View File

@ -601,8 +601,8 @@ int main( int argc, char **argv )
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
std::vector<std::string> arguments;
for(int i=1;i<argc;++i) arguments.push_back(argv[i]);
// initialize the viewer.
@ -611,14 +611,14 @@ int main( int argc, char **argv )
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
viewer.readCommandLine(arguments);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
osgDB::readCommandLine(arguments);
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)

View File

@ -21,7 +21,6 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
class MyUpdateCallback : public osg::NodeCallback
@ -364,70 +363,38 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph)
return parent;
}
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT
glutInit( &argc, argv );
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
if (argc<2)
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
// write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -17,7 +17,6 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
@ -307,34 +306,35 @@ osg::Node* createMirroredScene(osg::Node* model)
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
//write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)

View File

@ -18,72 +18,40 @@
#include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 1;
}

View File

@ -9,7 +9,6 @@
#include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer>
#include <osgGLUT/glut>
//
@ -69,25 +68,6 @@ private:
std::vector<osg::Sequence*>* _seq;
};
void write_usage(std::ostream& out, const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out<<std::endl;
}
osg::Sequence* generateSeq(osg::Sequence::LoopMode mode,
float speed, int nreps,
std::vector<osg::Node*>& model)
@ -114,39 +94,44 @@ osg::Sequence* generateSeq(osg::Sequence::LoopMode mode,
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
if (argc < 2)
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
write_usage(osg::notify(osg::NOTICE), argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create commandline args
std::vector<std::string> commandLine;
for (int ia = 1; ia < argc; ia++)
commandLine.push_back(argv[ia]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// initialize the viewer
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// assumes any remaining parameters are models
std::vector<osg::Node*> model;
unsigned int i;
for (i = 0; i < commandLine.size(); i++) {
std::cerr << "Loading " << commandLine[i] << std::endl;
osg::Node* node = osgDB::readNodeFile(commandLine[i]);
int i;
for (i = 1; i < arguments.argc(); i++)
{
std::cerr << "Loading " << arguments[i] << std::endl;
osg::Node* node = osgDB::readNodeFile(arguments[i]);
if (node)
model.push_back(node);
}
if (model.empty()) {
write_usage(osg::notify(osg::NOTICE),argv[0]);
return -1;
}

View File

@ -15,7 +15,6 @@
#include <osgGA/DriveManipulator>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
@ -172,25 +171,32 @@ osg::Node* createModel()
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* model = createModel();

View File

@ -6,7 +6,6 @@
#include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osgDB/ReadFile>
@ -85,21 +84,32 @@ osg::Geode* createShapes()
int main( int argc, char **argv )
{
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the viewer and the model to it.
osgGLUT::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;
}
viewer.setWindowTitle(argv[0]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
osg::Node* node = createShapes();

View File

@ -9,88 +9,49 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] image_left_eye image_right_eye"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
out<<"example:"<<std::endl;
out<<" Images/dog_left_eye.jpg Images/dog_right_eye.jpg"<<std::endl;
out<<std::endl;
}
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// default to enabling stereo.
viewer.getDisplaySettings()->setStereo(true);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
if (commandLine.size()<2)
if (arguments.argc()<=2)
{
osg::notify(osg::NOTICE) << "Please specify two images required for stereo imaging."<<std::endl;
return 0;
}
osg::Image* imageLeft = osgDB::readImageFile(commandLine[0]);
osg::Image* imageRight = osgDB::readImageFile(commandLine[1]);
osg::Image* imageLeft = osgDB::readImageFile(arguments[1]);
osg::Image* imageRight = osgDB::readImageFile(arguments[2]);
if (imageLeft && imageRight)

View File

@ -318,22 +318,32 @@ osg::Geode* createTeapot()
int main( int argc, char **argv )
{
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the viewer and the model to it.
osgGLUT::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;
}
viewer.setWindowTitle(argv[0]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// add model to viewer.
viewer.addViewport( createTeapot() );

View File

@ -420,28 +420,35 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::ref_ptr<osg::Node> rootNode = osgDB::readNodeFiles(commandLine);
osg::ref_ptr<osg::Node> rootNode = osgDB::readNodeFiles(arguments);
// prepare scene.
{

View File

@ -179,34 +179,35 @@ void write_usage(std::ostream& out,const std::string& name)
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the images specified on command line
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine);
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (loadedModel)

View File

@ -72,19 +72,17 @@ class Texture2DCallback : public osg::NodeCallback
* Function to read several images files (typically one) as specified
* on the command line, and return them in an ImageList
*/
ImageList getImagesFromFiles(std::vector<std::string>& commandLine)
ImageList getImagesFromFiles(osg::ArgumentParser& arguments)
{
ImageList imageList;
for(std::vector<std::string>::iterator itr=commandLine.begin();
itr!=commandLine.end();
++itr)
for(int i=1;i<arguments.argc();++i)
{
if ((*itr)[0]!='-')
if (!arguments.isOption(i))
{
// not an option so assume string is a filename.
osg::Image *image = osgDB::readImageFile( *itr );
osg::Image *image = osgDB::readImageFile( arguments[i] );
if (image)
{
imageList.push_back(image);
@ -389,72 +387,38 @@ osg::Node* createModelFromImages(ImageList& imageList)
return root;
}
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] image_infile1 [image_infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
out<<"example:"<<std::endl;
out<<" osgtexture lz.rgb"<<std::endl;
out<<std::endl;
}
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the images specified on command line
ImageList imageList = getImagesFromFiles(commandLine);
ImageList imageList = getImagesFromFiles(arguments);
if (!imageList.empty())
@ -479,7 +443,6 @@ int main( int argc, char **argv )
}
else
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
}

View File

@ -199,25 +199,32 @@ osg::Node* createModel()
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// create a model from the images.
osg::Node* rootNode = createModel();

View File

@ -1,14 +1,47 @@
#include <osg/UnitTestFramework>
#include <osg/ArgumentParser>
#include <osg/ApplicationUsage>
int main( int /*argc*/, char** /*argv*/ )
int main( int argc, char** argv )
{
// std::cout<<"***** Qualified Tests ******"<<std::endl;
//
// osgUtx::QualifiedTestPrinter printer;
// osgUtx::TestGraph::instance().root()->accept( printer );
// std::cout<<endl;
osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options]");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests.");
bool printQualifiedTest = false;
while (arguments.read("qt")) printQualifiedTest = true;
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
std::cout<<arguments.getApplicationUsage()->getCommandLineUsage()<<std::endl;
arguments.getApplicationUsage()->write(std::cout,arguments.getApplicationUsage()->getCommandLineOptions());
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
if (printQualifiedTest)
{
std::cout<<"***** Qualified Tests ******"<<std::endl;
osgUtx::QualifiedTestPrinter printer;
osgUtx::TestGraph::instance().root()->accept( printer );
std::cout<<endl;
}
std::cout<<"****** Running tests ******"<<std::endl;

View File

@ -344,32 +344,39 @@ osg::Node* addRefractStateSet(osg::Node* node)
int main(int argc, char *argv[])
{
// initialize the GLUT
glutInit( &argc, argv );
glutInitDisplayString("rgba double depth>=16");
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1; i<argc; ++i) commandLine.push_back(argv[i]);
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
osg::Group* rootnode = new osg::Group;
rootnode->addChild(createSkyBox());
// load the nodes from the commandline arguments.
osg::Node* model = osgDB::readNodeFiles(commandLine);
osg::Node* model = osgDB::readNodeFiles(arguments);
if (!model)
{
const float radius = 1.0f;

View File

@ -14,68 +14,38 @@
#include <osg/Quat>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv )
{
// initialize the GLUT
glutInit( &argc, argv );
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
// write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -1,6 +1,3 @@
#include <stdio.h>
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer>
#include <osg/Node>
@ -14,7 +11,6 @@
#include <osgGA/DriveManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgUtil/Optimizer>
struct SortByAverageDistanceFunctor
@ -51,87 +47,42 @@ struct MySortCallback : public osgUtil::RenderBin::SortCallback
}
};
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -O \"options string\" - create an options string to pass to the reader/wrter "<< std::endl;
out <<" for controlling reading and writing parameters."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out <<" -f - start with a full screen, borderless window." << std::endl;
out <<" -p pathfile - Use the AnimationPathManipulator (key binding '4') and use\n"
" pathfile to define the animation path. pathfile is an ascii\n"
" file containing lines of eight floating point numbers representing\n"
" time, position (x,y,z) and attitude (x,y,z,w as a quaternion)." << std::endl;
out << std::endl;
}
int main( int argc, char **argv )
{
// 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Use specificed animation path file for camera animation");
// read the commandline args.
std::string pathfile;
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) {
if( std::string(argv[i]) == "-p" ) {
if( (i+1) >= argc ) {
write_usage( std::cout, argv[0]);
return 1;
}
else
pathfile = std::string(argv[++i]);
}
else
commandLine.push_back(argv[i]);
}
while (arguments.read("-p",pathfile)) {}
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
osgGLUT::Viewer viewer(arguments);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
return 1;

View File

@ -224,77 +224,6 @@ void DisplaySettings::readEnvironmentalVariables()
}
}
void DisplaySettings::readCommandLine(std::vector<std::string>& commandLine)
{
bool found = true;
while (found)
{
found = false;
// check for stereo based options.
std::vector<std::string>::iterator itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-stereo") break;
}
if (itr!=commandLine.end())
{
_stereo = true;
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
if (*itr=="ANAGLYPHIC") { _stereo = true;_stereoMode = ANAGLYPHIC; ++itr; }
else if (*itr=="QUAD_BUFFER") { _stereo = true;_stereoMode = QUAD_BUFFER; ++itr; }
else if (*itr=="HORIZONTAL_SPLIT") { _stereo = true;_stereoMode = HORIZONTAL_SPLIT; ++itr; }
else if (*itr=="VERTICAL_SPLIT") { _stereo = true;_stereoMode = VERTICAL_SPLIT; ++itr; }
else if (*itr=="LEFT_EYE") { _stereo = true;_stereoMode = LEFT_EYE; ++itr; }
else if (*itr=="RIGHT_EYE") { _stereo = true;_stereoMode = RIGHT_EYE; ++itr; }
else if (*itr=="ON") { _stereo = true; ++itr; }
else if (*itr=="OFF") { _stereo = false; ++itr; }
}
commandLine.erase(start,itr);
found = true;
}
// check destination alpha
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-rgba") break;
}
if (itr!=commandLine.end())
{
_RGB = true;
_minimumNumberAlphaBits = 1;
commandLine.erase(itr);
found = true;
}
// check stencil buffer
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-stencil") break;
}
if (itr!=commandLine.end())
{
_minimumNumberStencilBits = 1;
commandLine.erase(itr);
found = true;
}
}
}
void DisplaySettings::readCommandLine(ArgumentParser& arguments)
{

View File

@ -71,6 +71,8 @@ Registry::Registry()
addFileExtensionAlias("jpeg", "qt");
addFileExtensionAlias("tif", "qt");
addFileExtensionAlias("tiff", "qt");
addFileExtensionAlias("gif", "qt");
addFileExtensionAlias("png", "qt");
#else
addFileExtensionAlias("jpg", "jpeg");
addFileExtensionAlias("jpe", "jpeg");
@ -225,79 +227,6 @@ void Registry::initLibraryFilePathList()
}
void Registry::readCommandLine(std::vector<std::string>& commandLine)
{
bool found = true;
while (found)
{
found = false;
// load library option.
std::vector<std::string>::iterator itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-l") break;
}
if (itr!=commandLine.end())
{
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
loadLibrary(*itr);
++itr;
}
commandLine.erase(start,itr);
found = true;
}
// load library for extension
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-e") break;
}
if (itr!=commandLine.end())
{
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
std::string libName = osgDB::Registry::instance()->createLibraryNameForExt(*itr);
loadLibrary(libName);
++itr;
}
commandLine.erase(start,itr);
found = true;
}
// read any option strings that exist.
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-O") break;
}
if (itr!=commandLine.end())
{
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
osgDB::Registry::instance()->setOptions(new osgDB::ReaderWriter::Options(*itr));
++itr;
}
commandLine.erase(start,itr);
found = true;
}
}
}
void Registry::readCommandLine(osg::ArgumentParser& arguments)
{
// report the usage options.

View File

@ -36,9 +36,11 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
{
if(!_drawState.valid()) return false;
if(ea.getEventType()==GUIEventAdapter::KEYDOWN){
if(ea.getEventType()==GUIEventAdapter::KEYDOWN)
{
switch( ea.getKey() ){
switch( ea.getKey() )
{
case 'b' :
_backface = !_backface;
@ -64,24 +66,24 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
return true;
break;
case 'w' :
{
osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_drawState->getAttribute(osg::StateAttribute::POLYGONMODE));
if (!polyModeObj)
case 'w' :
{
polyModeObj = new osg::PolygonMode;
_drawState->setAttribute(polyModeObj);
osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_drawState->getAttribute(osg::StateAttribute::POLYGONMODE));
if (!polyModeObj)
{
polyModeObj = new osg::PolygonMode;
_drawState->setAttribute(polyModeObj);
}
// cycle through the available modes.
switch(polyModeObj->getMode(osg::PolygonMode::FRONT_AND_BACK))
{
case osg::PolygonMode::FILL : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); break;
case osg::PolygonMode::LINE : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::POINT); break;
case osg::PolygonMode::POINT : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL); break;
}
}
// cycle through the available modes.
switch(polyModeObj->getMode(osg::PolygonMode::FRONT_AND_BACK))
{
case osg::PolygonMode::FILL : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); break;
case osg::PolygonMode::LINE : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::POINT); break;
case osg::PolygonMode::POINT : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL); break;
}
}
break;
break;
}
}
return false;

View File

@ -20,6 +20,7 @@
#include <osgGLUT/Viewer>
#include <osgGLUT/GLUTEventAdapter>
#include <osg/ApplicationUsage>
#include <osg/Switch>
#include <osg/Billboard>
#include <osg/LOD>
@ -39,6 +40,7 @@
#include <osg/Fog>
#include <osgDB/WriteFile>
#include <osgDB/Registry>
#include <osgUtil/IntersectVisitor>
#include <osgUtil/DisplayListVisitor>
@ -88,6 +90,22 @@ using namespace std;
Viewer* Viewer::s_theViewer = 0;
Viewer::Viewer()
{
initialize();
}
Viewer::Viewer(osg::ArgumentParser& arguments)
{
initialize();
glutInit( &arguments.argc(), arguments.argv() );
setWindowTitle(arguments.getProgramName().c_str());
readCommandLine(arguments);
}
void Viewer::initialize()
{
s_theViewer = this;
@ -147,24 +165,27 @@ void Viewer::clear()
Window::clear();
}
/** read the command line string list, removing any matched control sequences.*/
void Viewer::readCommandLine(std::vector<std::string>& commandLine)
void Viewer::readCommandLine(osg::ArgumentParser& arguments)
{
std::vector<std::string>::iterator itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
// report the usage options.
if (arguments.getApplicationUsage())
{
if (*itr=="-f")
{
_fullscreen = true;
break;
}
arguments.getApplicationUsage()->addCommandLineOption("-f","open the application in fullscreen mode");
}
_displaySettings->readCommandLine(commandLine);
while(arguments.read("-f"))
{
_fullscreen = true;
}
_displaySettings->readCommandLine(arguments);
osgDB::readCommandLine(arguments);
}
void
Viewer::toggleFullScreen()
void Viewer::toggleFullScreen()
{
_fullscreen = !_fullscreen;
if (_fullscreen)