Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eVolve/localInitData.cpp
1 
2 /* Copyright (c) 2007-2014, 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 #ifndef MIN
37 # define MIN LB_MIN
38 #endif
39 
40 namespace po = boost::program_options;
41 
42 namespace eVolve
43 {
44 LocalInitData::LocalInitData()
45  : _maxFrames( 0xffffffffu )
46  , _isResident( false )
47  , _ortho( false )
48 {}
49 
50 const LocalInitData& LocalInitData::operator = ( const LocalInitData& from )
51 {
52  _maxFrames = from._maxFrames;
53  _isResident = from._isResident;
54  _ortho = from._ortho;
55 
56  setFilename( from.getFilename( ));
57  setWindowSystem( from.getWindowSystem( ));
58  setPrecision( from.getPrecision( ));
59  setBrightness( from.getBrightness( ));
60  setAlpha( from.getAlpha( ));
61  return *this;
62 }
63 
64 void LocalInitData::parseArguments( const int argc, char** argv )
65 {
66  std::string wsHelp = "Window System API ( one of: ";
67 #ifdef AGL
68  wsHelp += "AGL ";
69 #endif
70 #ifdef GLX
71  wsHelp += "GLX ";
72 #endif
73 #ifdef WGL
74  wsHelp += "WGL ";
75 #endif
76 #ifdef EQUALIZER_USE_QT4
77  wsHelp += "Qt ";
78 #endif
79  wsHelp += ")";
80 
81  bool showHelp(false);
82  uint32_t userDefinedPrecision(2);
83  float userDefinedBrightness(1.0f);
84  float userDefinedAlpha(1.0f);
85  std::string userDefinedModelPath("");
86  std::string userDefinedWindowSystem("");
87 
88  const std::string& desc = EVolve::getHelp();
89  po::options_description options( desc + " Version " +
91  options.add_options()
92  ( "help,h", po::bool_switch(&showHelp)->default_value(false),
93  "produce help message" )
94  ( "model,m", po::value<std::string>(&userDefinedModelPath),
95  "raw model file name, e.g. Bucky32x32x32.raw" )
96  ( "resident,r", po::bool_switch(&_isResident)->default_value(false),
97  "Keep client resident (see resident mode documentation on website)" )
98  ( "numFrames,n",
99  po::value<uint32_t>(&_maxFrames)->default_value(0xffffffffu),
100  "Maximum number of rendered frames")
101  ( "precision,p",
102  po::value<uint32_t>(&userDefinedPrecision)->default_value(2),
103  "Rendering precision (default 2, bigger is better and slower)")
104  ( "brightness,b",
105  po::value<float>(&userDefinedBrightness)->default_value(1.0f),
106  "brightness factor" )
107  ( "alpha,a",
108  po::value<float>(&userDefinedAlpha)->default_value(1.0f),
109  "alpha attenuation" )
110  ( "ortho,o", po::bool_switch(&_ortho)->default_value(false),
111  "use orthographic projection" )
112  ( "windowSystem,w",
113  po::value<std::string>(&userDefinedWindowSystem),
114  wsHelp.c_str( ));
115 
116  po::variables_map variableMap;
117  try
118  {
119  // parse program options, ignore non related options
120  po::store( po::command_line_parser( argc, argv ).options(
121  options ).allow_unregistered().run(),
122  variableMap );
123  po::notify(variableMap);
124  }
125  catch( std::exception& exception )
126  {
127  LBERROR << "Error parsing command line: " << exception.what()
128  << std::endl;
129  eq::exit();
130  ::exit( EXIT_FAILURE );
131  }
132 
133  // Evaluate parsed command line options
134  if( showHelp )
135  {
136  std::cout << options << std::endl;
137  eq::exit();
138  ::exit( EXIT_SUCCESS );
139  }
140 
141  if ( variableMap.count( "model" ) > 0 )
142  setFilename( userDefinedModelPath );
143 
144  if( variableMap.count( "windowSystem" ) > 0 )
145  setWindowSystem( userDefinedWindowSystem );
146 
147 
148  if( variableMap.count("precision") > 0 )
149  setPrecision( userDefinedPrecision );
150  if( variableMap.count("brightness") > 0 )
151  setBrightness( userDefinedBrightness );
152  if( variableMap.count("alpha") > 0 )
153  setAlpha( userDefinedAlpha );
154 }
155 
156 }
static std::string getString()
EQFABRIC_API bool exit()
De-initialize the Equalizer fabric namespace.
EQ_API bool exit()
De-initialize the Equalizer client library.