Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eqPly/localInitData.cpp
1 
2 /* Copyright (c) 2007-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * - Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  * - Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * - Neither the name of Eyescale Software GmbH nor the names of its
13  * contributors may be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "localInitData.h"
30 #include "frameData.h"
31 
32 #pragma warning( disable: 4275 )
33 #include <boost/program_options.hpp>
34 #pragma warning( default: 4275 )
35 
36 #include <cctype>
37 
38 #ifndef MIN
39 # define MIN LB_MIN
40 #endif
41 
42 namespace po = boost::program_options;
43 
44 namespace eqPly
45 {
46 LocalInitData::LocalInitData()
47  : _pathFilename("")
48  , _maxFrames( 0xffffffffu )
49  , _color( true )
50  , _isResident( false )
51 {
52  _filenames.push_back( lunchbox::getExecutablePath() +
53  "/../share/Equalizer/data" );
54 }
55 
56 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from )
57 {
58  _maxFrames = from._maxFrames;
59  _color = from._color;
60  _isResident = from._isResident;
61  _filenames = from._filenames;
62  _pathFilename = from._pathFilename;
63 
64  setWindowSystem( from.getWindowSystem( ));
65  setRenderMode( from.getRenderMode( ));
66  if( from.useGLSL( ))
67  enableGLSL();
68  if( from.useInvertedFaces( ))
69  enableInvertedFaces();
70  if( !from.showLogo( ))
71  disableLogo();
72  if( !from.useROI( ))
73  disableROI();
74 
75  return *this;
76 }
77 
78 void LocalInitData::parseArguments( const int argc, char** argv )
79 {
80  std::string wsHelp = "Window System API ( one of: ";
81 #ifdef AGL
82  wsHelp += "AGL ";
83 #endif
84 #ifdef GLX
85  wsHelp += "GLX ";
86 #endif
87 #ifdef WGL
88  wsHelp += "WGL ";
89 #endif
90 #ifdef EQUALIZER_USE_QT4
91  wsHelp += "Qt ";
92 #endif
93  wsHelp += ")";
94 
95  bool showHelp( false );
96  std::vector<std::string> userDefinedModelPath;
97  bool userDefinedBlackWhiteMode( false );
98  std::string userDefinedWindowSystem("");
99  std::string userDefinedRenderMode("");
100  bool userDefinedUseGLSL( false );
101  bool userDefinedInvertFaces( false );
102  bool userDefinedDisableLogo( false );
103  bool userDefinedDisableROI( false );
104 
105  const std::string& desc = EqPly::getHelp();
106  po::options_description options( desc + " Version " +
108  options.add_options()
109  ( "help,h", po::bool_switch(&showHelp)->default_value( false ),
110  "produce help message" )
111  ( "model,m",
112  po::value<std::vector<std::string> >( &userDefinedModelPath ),
113  "ply model file names or directories" )
114  ( "blackAndWhite,b",
115  po::bool_switch(&userDefinedBlackWhiteMode)->default_value( false ),
116  "Don't use colors from ply file" )
117  ( "resident,r", po::bool_switch(&_isResident)->default_value( false ),
118  "Keep client resident (see resident mode documentation on website)" )
119  ( "numFrames,n",
120  po::value<uint32_t>(&_maxFrames)->default_value(0xffffffffu),
121  "Maximum number of rendered frames")
122  ( "windowSystem,w", po::value<std::string>( &userDefinedWindowSystem ),
123  wsHelp.c_str() )
124  ( "renderMode,c", po::value<std::string>( &userDefinedRenderMode ),
125  "Rendering Mode (immediate|displayList|VBO)" )
126  ( "glsl,g",
127  po::bool_switch(&userDefinedUseGLSL)->default_value( false ),
128  "Enable GLSL shaders" )
129  ( "invertFaces,i"
130  , po::bool_switch(&userDefinedInvertFaces)->default_value( false ),
131  "Invert faces (valid during binary file creation)" )
132  ( "cameraPath,a", po::value<std::string>(&_pathFilename),
133  "File containing camera path animation" )
134  ( "noOverlay,o",
135  po::bool_switch(&userDefinedDisableLogo)->default_value( false ),
136  "Disable overlay logo" )
137  ( "disableROI,d",
138  po::bool_switch(&userDefinedDisableROI)->default_value( false ),
139  "Disable region of interest (ROI)" );
140 
141  po::variables_map variableMap;
142 
143  try
144  {
145  // parse program options, ignore all non related options
146  po::store( po::command_line_parser( argc, argv ).options(
147  options ).allow_unregistered().run(),
148  variableMap );
149  po::notify( variableMap );
150  }
151  catch( std::exception& exception )
152  {
153  LBERROR << "Error parsing command line: " << exception.what()
154  << std::endl;
155  eq::exit();
156  ::exit( EXIT_FAILURE );
157  }
158 
159 
160  // Evaluate parsed command line options
161  if( showHelp )
162  {
163  std::cout << options << std::endl;
164  eq::exit();
165  ::exit( EXIT_SUCCESS );
166  }
167 
168  if( variableMap.count("model") > 0 )
169  {
170  _filenames.clear();
171  _filenames = userDefinedModelPath;
172  }
173 
174  _color = !userDefinedBlackWhiteMode;
175 
176  if( variableMap.count("windowSystem") > 0 )
177  setWindowSystem( userDefinedWindowSystem );
178 
179  if( variableMap.count("renderMode") > 0 )
180  {
181  std::transform( userDefinedRenderMode.begin(),
182  userDefinedRenderMode.end(),
183  userDefinedRenderMode.begin(),
184  (int(*)(int))std::tolower );
185 
186  if( userDefinedRenderMode == "immediate" )
187  setRenderMode( triply::RENDER_MODE_IMMEDIATE );
188  else if( userDefinedRenderMode == "displaylist" )
189  setRenderMode( triply::RENDER_MODE_DISPLAY_LIST );
190  else if( userDefinedRenderMode == "vbo" )
191  setRenderMode( triply::RENDER_MODE_BUFFER_OBJECT );
192  }
193 
194  if( userDefinedUseGLSL )
195  enableGLSL();
196 
197  if( userDefinedInvertFaces)
198  enableInvertedFaces();
199 
200  if( userDefinedDisableLogo )
201  disableLogo();
202 
203  if( userDefinedDisableROI )
204  disableROI();
205 }
206 
207 }
static std::string getString()
EQFABRIC_API bool exit()
De-initialize the Equalizer fabric namespace.
EQ_API bool exit()
De-initialize the Equalizer client library.