Equalizer
1.4.1
|
00001 00002 /* Copyright (c) 2007-2012, 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 LB_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, ' ', eq::Version::getString( )); 00082 TCLAP::ValueArg<std::string> modelArg( "m", "model", 00083 "raw model file name", 00084 false, "Bucky32x32x32.raw", 00085 "string", command ); 00086 TCLAP::SwitchArg residentArg( "r", "resident", 00087 "Keep client resident (see resident node documentation on website)", 00088 command, false ); 00089 TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames", 00090 "Maximum number of rendered frames", 00091 false, 0xffffffffu, "unsigned", 00092 command ); 00093 TCLAP::ValueArg<uint32_t> precisionArg( "p", "precision", 00094 "Rendering precision (default 2, bigger is better and slower)", 00095 false, 2, "unsigned", 00096 command ); 00097 TCLAP::ValueArg<float> brightnessArg( "b", "brightness", 00098 "brightness factor", false, 1.0f, 00099 "float", command ); 00100 TCLAP::ValueArg<float> alphaArg( "a", "alpha", "alpha attenuation", 00101 false, 1.0f, "float", command ); 00102 TCLAP::SwitchArg orthoArg( "o", "ortho", 00103 "use orthographic projection", 00104 command, false ); 00105 TCLAP::ValueArg<std::string> wsArg( "w", "windowSystem", wsHelp, 00106 false, "auto", "string", command ); 00107 TCLAP::VariableSwitchArg ignoreEqArgs( "eq", 00108 "Ignored Equalizer options", 00109 command ); 00110 TCLAP::UnlabeledMultiArg< std::string > 00111 ignoreArgs( "ignore", "Ignored unlabeled arguments", false, "any", 00112 command ); 00113 00114 command.parse( argc, argv ); 00115 00116 if( modelArg.isSet( )) 00117 setFilename( modelArg.getValue( )); 00118 if( wsArg.isSet( )) 00119 { 00120 std::string windowSystem = wsArg.getValue(); 00121 transform( windowSystem.begin(), windowSystem.end(), 00122 windowSystem.begin(), (int(*)(int))std::toupper ); 00123 00124 setWindowSystem( windowSystem ); 00125 } 00126 00127 if( framesArg.isSet( )) 00128 _maxFrames = framesArg.getValue(); 00129 if( precisionArg.isSet( )) 00130 setPrecision( precisionArg.getValue( )); 00131 if( brightnessArg.isSet( )) 00132 setBrightness( brightnessArg.getValue( )); 00133 if( alphaArg.isSet( )) 00134 setAlpha( alphaArg.getValue( )); 00135 if( residentArg.isSet( )) 00136 _isResident = true; 00137 if( orthoArg.isSet( )) 00138 _ortho = true; 00139 } 00140 catch( const TCLAP::ArgException& exception ) 00141 { 00142 LBERROR << "Command line parse error: " << exception.error() 00143 << " for argument " << exception.argId() << std::endl; 00144 ::exit( EXIT_FAILURE ); 00145 } 00146 } 00147 } 00148