// PerformVariableSubstitutions //------------------------------------------------------------------------------ /*static*/ bool BFFParser::PerformVariableSubstitutions( const BFFIterator & startIter, const BFFIterator & endIter, AString & value ) { AStackString< 4096 > output; BFFIterator src( startIter ); BFFIterator end( endIter ); while ( src < end ) { switch ( *src ) { case '^': { src++; // skip escape char if ( src < end ) { output += *src; // append escaped character } break; } case '$': { BFFIterator firstToken( src ); src++; // skip opening $ // find matching $ BFFIterator startName( src ); const char * endName = nullptr; while ( src < end ) { if ( *src == '$' ) { endName = src.GetCurrent(); break; } src++; } if ( ( endName == nullptr ) || ( ( endName - startName.GetCurrent() ) < 1 ) ) { Error::Error_1028_MissingVariableSubstitutionEnd( firstToken ); return false; } AStackString< MAX_VARIABLE_NAME_LENGTH > varName( startName.GetCurrent(), endName ); const BFFVariable * var = BFFStackFrame::GetVarAny( varName ); if ( var == nullptr ) { Error::Error_1009_UnknownVariable( startName, nullptr ); return false; } if ( var->IsString() == false ) { Error::Error_1029_VariableForSubstitutionIsNotAString( startName, varName, var->GetType() ); return false; } output += var->GetString(); break; } default: { output += *src; break; } } src++; } value = output; return true; }
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()->setDescription(arguments.getApplicationName()+" is the example which demonstrates ping pong rendering with FBOs and mutliple rendering branches. It uses Conway's Game of Life to illustrate the concept."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] --startim start_image"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("--startim","The initial image to seed the game of life with."); // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) { arguments.getApplicationUsage()->write(std::cout); return 1; } std::string startName(""); while(arguments.read("--startim", startName)) {} if (startName == "") { arguments.getApplicationUsage()->write(std::cout); return 1; } // load the image osg::ref_ptr<osg::Image> startIm = osgDB::readImageFile(startName); if (!startIm) { std::cout << "Could not load start image.\n"; return(1); } osg::Node* scene = createScene(startIm.get()); // construct the viewer. osgViewer::Viewer viewer; viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); // add the stats handler viewer.addEventHandler(new osgViewer::StatsHandler); viewer.setSceneData(scene); viewer.realize(); viewer.setCameraManipulator( new osgGA::TrackballManipulator ); while(!viewer.done()) { viewer.frame(); // flip the textures after we've completed a frame golpass->flip(); // attach the proper output to view geomss->setTextureAttributeAndModes(0, golpass->getOutputTexture().get(), osg::StateAttribute::ON); } return 0; }