|
Equalizer
1.3.1-git
|
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 eqPly 00042 { 00043 LocalInitData::LocalInitData() 00044 : _maxFrames( 0xffffffffu ) 00045 , _color( true ) 00046 , _isResident( false ) 00047 { 00048 #ifdef EQ_RELEASE 00049 # ifdef _WIN32 // final INSTALL_DIR is not known at compile time 00050 _filenames.push_back( "../share/Equalizer/data" ); 00051 # else 00052 _filenames.push_back( std::string( EQ_INSTALL_DIR ) + 00053 std::string( "share/Equalizer/data" )); 00054 # endif 00055 #else 00056 _filenames.push_back( std::string( EQ_SOURCE_DIR ) + 00057 std::string( "examples/eqPly" )); 00058 #endif 00059 } 00060 00061 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from ) 00062 { 00063 _trackerPort = from._trackerPort; 00064 _maxFrames = from._maxFrames; 00065 _color = from._color; 00066 _isResident = from._isResident; 00067 _filenames = from._filenames; 00068 _pathFilename = from._pathFilename; 00069 00070 setWindowSystem( from.getWindowSystem( )); 00071 setRenderMode( from.getRenderMode( )); 00072 if( from.useGLSL( )) 00073 enableGLSL(); 00074 if( from.useInvertedFaces( )) 00075 enableInvertedFaces(); 00076 if( !from.showLogo( )) 00077 disableLogo(); 00078 if( !from.useROI( )) 00079 disableROI(); 00080 00081 return *this; 00082 } 00083 00084 void LocalInitData::parseArguments( const int argc, char** argv ) 00085 { 00086 try 00087 { 00088 std::string wsHelp = "Window System API ( one of: "; 00089 #ifdef AGL 00090 wsHelp += "AGL "; 00091 #endif 00092 #ifdef GLX 00093 wsHelp += "glX "; 00094 #endif 00095 #ifdef WGL 00096 wsHelp += "WGL "; 00097 #endif 00098 wsHelp += ")"; 00099 00100 const std::string& desc = EqPly::getHelp(); 00101 00102 TCLAP::CmdLine command( desc ); 00103 TCLAP::MultiArg<std::string> modelArg( "m", "model", 00104 "ply model file name or directory", 00105 false, "string", command ); 00106 TCLAP::ValueArg<std::string> portArg( "p", "port", 00107 "tracking device port", 00108 false, "/dev/ttyS0", "string", 00109 command ); 00110 TCLAP::SwitchArg colorArg( "b", "blackAndWhite", 00111 "Don't use colors from ply file", 00112 command, false ); 00113 TCLAP::SwitchArg residentArg( "r", "resident", 00114 "Keep client resident (see resident node documentation on website)", 00115 command, false ); 00116 TCLAP::ValueArg<uint32_t> framesArg( "n", "numFrames", 00117 "Maximum number of rendered frames", 00118 false, 0xffffffffu, "unsigned", 00119 command ); 00120 TCLAP::ValueArg<std::string> wsArg( "w", "windowSystem", wsHelp, 00121 false, "auto", "string", command ); 00122 TCLAP::ValueArg<std::string> modeArg( "c", "renderMode", 00123 "Rendering Mode (immediate, displayList, VBO)", 00124 false, "auto", "string", 00125 command ); 00126 TCLAP::SwitchArg glslArg( "g", "glsl", "Enable GLSL shaders", 00127 command, false ); 00128 TCLAP::SwitchArg invFacesArg( "i", "invertFaces", 00129 "Invert faces (valid during binary file creation)", 00130 command, false ); 00131 TCLAP::ValueArg<std::string> pathArg( "a", "cameraPath", 00132 "File containing camera path animation", 00133 false, "", "string", command ); 00134 TCLAP::SwitchArg overlayArg( "o", "noOverlay", "Disable overlay logo", 00135 command, false ); 00136 TCLAP::VariableSwitchArg ignoreEqArgs( "eq", 00137 "Ignored Equalizer options", 00138 command ); 00139 TCLAP::UnlabeledMultiArg< std::string > 00140 ignoreArgs( "ignore", "Ignored unlabeled arguments", false, "any", 00141 command ); 00142 TCLAP::SwitchArg roiArg( "d", "disableROI", "Disable ROI", command, 00143 false ); 00144 00145 command.parse( argc, argv ); 00146 00147 if( modelArg.isSet( )) 00148 { 00149 _filenames.clear(); 00150 _filenames = modelArg.getValue(); 00151 } 00152 if( portArg.isSet( )) 00153 _trackerPort = portArg.getValue(); 00154 if( wsArg.isSet( )) 00155 { 00156 std::string windowSystem = wsArg.getValue(); 00157 transform( windowSystem.begin(), windowSystem.end(), 00158 windowSystem.begin(), (int(*)(int))std::toupper ); 00159 00160 setWindowSystem( windowSystem ); 00161 } 00162 00163 _color = !colorArg.isSet(); 00164 00165 if( framesArg.isSet( )) 00166 _maxFrames = framesArg.getValue(); 00167 00168 if( residentArg.isSet( )) 00169 _isResident = true; 00170 00171 if( modeArg.isSet() ) 00172 { 00173 std::string mode = modeArg.getValue(); 00174 transform( mode.begin(), mode.end(), mode.begin(), 00175 (int(*)(int))std::tolower ); 00176 00177 if( mode == "immediate" ) 00178 setRenderMode( mesh::RENDER_MODE_IMMEDIATE ); 00179 else if( mode == "displaylist" ) 00180 setRenderMode( mesh::RENDER_MODE_DISPLAY_LIST ); 00181 else if( mode == "vbo" ) 00182 setRenderMode( mesh::RENDER_MODE_BUFFER_OBJECT ); 00183 } 00184 00185 if( pathArg.isSet( )) 00186 _pathFilename = pathArg.getValue(); 00187 00188 if( glslArg.isSet() ) 00189 enableGLSL(); 00190 if( invFacesArg.isSet() ) 00191 enableInvertedFaces(); 00192 if( overlayArg.isSet( )) 00193 disableLogo(); 00194 if( roiArg.isSet( )) 00195 disableROI(); 00196 } 00197 catch( const TCLAP::ArgException& exception ) 00198 { 00199 LBERROR << "Command line parse error: " << exception.error() 00200 << " for argument " << exception.argId() << std::endl; 00201 ::exit( EXIT_FAILURE ); 00202 } 00203 } 00204 } 00205
1.3.1-git by
1.8.0