Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2007-2011, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * - Redistributions of source code must retain the above copyright notice, this 00008 * list of conditions and the following disclaimer. 00009 * - Redistributions in binary form must reproduce the above copyright notice, 00010 * this list of conditions and the following disclaimer in the documentation 00011 * and/or other materials provided with the distribution. 00012 * - Neither the name of Eyescale Software GmbH nor the names of its 00013 * contributors may be used to endorse or promote products derived from this 00014 * software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00019 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00020 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00022 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00025 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00026 * POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00029 #include "localInitData.h" 00030 #include "frameData.h" 00031 00032 #include <algorithm> 00033 #include <cctype> 00034 #include <functional> 00035 00036 #ifndef MIN 00037 # define MIN EQ_MIN 00038 #endif 00039 #include <tclap/CmdLine.h> 00040 00041 namespace eVolve 00042 { 00043 LocalInitData::LocalInitData() 00044 : _maxFrames( 0xffffffffu ) 00045 , _isResident( false ) 00046 , _ortho( false ) 00047 {} 00048 00049 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from ) 00050 { 00051 _maxFrames = from._maxFrames; 00052 _isResident = from._isResident; 00053 _ortho = from._ortho; 00054 00055 setFilename( from.getFilename( )); 00056 setWindowSystem( from.getWindowSystem( )); 00057 setPrecision( from.getPrecision( )); 00058 setBrightness( from.getBrightness( )); 00059 setAlpha( from.getAlpha( )); 00060 return *this; 00061 } 00062 00063 void LocalInitData::parseArguments( const int argc, char** argv ) 00064 { 00065 try 00066 { 00067 std::string wsHelp = "Window System API ( one of: "; 00068 #ifdef AGL 00069 wsHelp += "AGL "; 00070 #endif 00071 #ifdef GLX 00072 wsHelp += "glX "; 00073 #endif 00074 #ifdef WGL 00075 wsHelp += "WGL "; 00076 #endif 00077 wsHelp += ")"; 00078 00079 std::string desc = EVolve::getHelp(); 00080 00081 TCLAP::CmdLine command( desc ); 00082 00083 TCLAP::ValueArg<std::string> modelArg( "m", "model", 00084 "raw model file name", 00085 false, "Bucky32x32x32.raw", 00086 "string", command ); 00087 TCLAP::SwitchArg residentArg( "r", "resident", 00088 "Keep client resident (see resident node documentation on website)", 00089 command, false ); 00090 TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames", 00091 "Maximum number of rendered frames", 00092 false, 0xffffffffu, "unsigned", 00093 command ); 00094 TCLAP::ValueArg<uint32_t> precisionArg( "p", "precision", 00095 "Rendering precision (default 2, bigger is better and slower)", 00096 false, 2, "unsigned", 00097 command ); 00098 TCLAP::ValueArg<float> brightnessArg( "b", "brightness", 00099 "brightness factor", false, 1.0f, 00100 "float", command ); 00101 TCLAP::ValueArg<float> alphaArg( "a", "alpha", "alpha attenuation", 00102 false, 1.0f, "float", command ); 00103 TCLAP::SwitchArg orthoArg( "o", "ortho", 00104 "use orthographic projection", 00105 command, false ); 00106 TCLAP::ValueArg<std::string> wsArg( "w", "windowSystem", wsHelp, 00107 false, "auto", "string", command ); 00108 TCLAP::VariableSwitchArg ignoreEqArgs( "eq", 00109 "Ignored Equalizer options", 00110 command ); 00111 TCLAP::UnlabeledMultiArg< std::string > 00112 ignoreArgs( "ignore", "Ignored unlabeled arguments", false, "any", 00113 command ); 00114 00115 command.parse( argc, argv ); 00116 00117 if( modelArg.isSet( )) 00118 setFilename( modelArg.getValue( )); 00119 if( wsArg.isSet( )) 00120 { 00121 std::string windowSystem = wsArg.getValue(); 00122 transform( windowSystem.begin(), windowSystem.end(), 00123 windowSystem.begin(), (int(*)(int))std::toupper ); 00124 00125 setWindowSystem( windowSystem ); 00126 } 00127 00128 if( framesArg.isSet( )) 00129 _maxFrames = framesArg.getValue(); 00130 if( precisionArg.isSet( )) 00131 setPrecision( precisionArg.getValue( )); 00132 if( brightnessArg.isSet( )) 00133 setBrightness( brightnessArg.getValue( )); 00134 if( alphaArg.isSet( )) 00135 setAlpha( alphaArg.getValue( )); 00136 if( residentArg.isSet( )) 00137 _isResident = true; 00138 if( orthoArg.isSet( )) 00139 _ortho = true; 00140 } 00141 catch( const TCLAP::ArgException& exception ) 00142 { 00143 EQERROR << "Command line parse error: " << exception.error() 00144 << " for argument " << exception.argId() << std::endl; 00145 ::exit( EXIT_FAILURE ); 00146 } 00147 } 00148 } 00149