Show
Ignore:
Timestamp:
04/14/14 18:16:22 (7 days ago)
Author:
robert
Message:

Fixed comment

Files:
1 modified

Legend:

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

    r12985 r14015  
    3131    searchAndReplace(shaderSource, "\r", "\n"); 
    3232    searchAndReplace(shaderSource, "\"", "\\\""); 
    33   
     33 
    3434    std::string variableString = std::string("char ")+variableName+std::string("[] = "); 
    35      
     35 
    3636    std::string::size_type startOfLine = 0; 
    3737    std::string::size_type endOfLine = shaderSource.find_first_of('\n', startOfLine); 
    38      
    39     if (endOfLine==std::string::npos)  
     38 
     39    if (endOfLine==std::string::npos) 
    4040    { 
    4141        fout<<variableString<<shaderSource<<"\\n\";"<<std::endl; 
     
    6464    // use an ArgumentParser object to manage the program arguments. 
    6565    osg::ArgumentParser arguments(&argc,argv); 
    66      
     66 
    6767    // set up the usage document, in case we need to print out how to use this program. 
    6868    arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); 
     
    7070    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    7171    arguments.getApplicationUsage()->addCommandLineOption("--shader <filename>","Shader file to create a .cpp file for."); 
     72    arguments.getApplicationUsage()->addCommandLineOption("--write-to-source-file-directory","Use the path to the source filename as the directory to write to."); 
    7273    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters"); 
    7374 
    7475    // if user request help write it out to cout. 
    7576    if (arguments.read("-h") || arguments.read("--help")) 
    76     {  
     77    { 
    7778        arguments.getApplicationUsage()->write(std::cout); 
    7879        return 1; 
    7980    } 
    80      
     81 
     82    bool useSamePathAsSourceFile = false; 
     83    if (arguments.read("--write-to-source-file-directory")) useSamePathAsSourceFile = true; 
     84 
    8185    std::string filename; 
    8286    if (arguments.read("--shader",filename)) 
     
    9599                pos = name.find_first_of(invalidCharacters); 
    96100            } 
    97              
     101 
    98102            std::string ext = osgDB::getFileExtension(filename); 
    99             std::string cppFileName = osgDB::concatPaths(path, name + "_" + ext + ".cpp"); 
     103            std::string cppFileName = name + "_" + ext + ".cpp"; 
     104            if (useSamePathAsSourceFile) cppFileName = osgDB::concatPaths(path, cppFileName); 
     105 
    100106            std::string variableName = name + "_" + ext; 
    101107            writeShader(shader.get(), cppFileName, variableName); 
     
    108114            return 1; 
    109115        } 
    110          
     116 
    111117    } 
    112118