1 // options.hxx -- class to handle command line options
3 // Written by Curtis Olson, started April 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 // (Log is kept at end of this file)
30 # error This library requires C++
46 #ifdef NEEDNAMESPACESTD
69 static const int FG_RADIUS_MIN = 1;
70 static const int FG_RADIUS_MAX = 4;
74 // The flight gear "root" directory
77 // Starting position and orientation
78 string airport_id; // ID of initial starting airport
79 double lon; // starting longitude in degrees (west = -)
80 double lat; // starting latitude in degrees (south = -)
81 double altitude; // starting altitude in meters
82 double heading; // heading (yaw) angle in degress (Psi)
83 double roll; // roll angle in degrees (Phi)
84 double pitch; // pitch angle in degrees (Theta)
87 bool game_mode; // Game mode enabled/disabled
88 bool splash_screen; // show splash screen
89 bool intro_music; // play introductory music
90 int mouse_pointer; // show mouse pointer
91 bool pause; // pause intially enabled/disabled
94 bool hud_status; // HUD on/off
95 bool panel_status; // Panel on/off
96 bool sound; // play sound effects
98 // Flight Model options
99 int flight_model; // Flight Model: FG_SLEW, FG_LARCSIM, etc.
102 fgFogKind fog; // Fog nicest/fastest/disabled
103 double fov; // Field of View
104 bool fullscreen; // Full screen mode enabled/disabled
105 int shading; // shading method, 0 = Flat, 1 = Smooth
106 bool skyblend; // Blend sky to haze (using polygons) or just clear
107 bool textures; // Textures enabled/disabled
108 bool wireframe; // Wireframe mode enabled/disabled
111 int tile_radius; // Square radius of rendered tiles (around center
113 int tile_diameter; // Diameter of rendered tiles. for instance
114 // if tile_diameter = 3 then a 3 x 3 grid of tiles will
115 // be drawn. Increase this to see terrain that is
122 int time_offset; // Offset true time by this many seconds
129 // Parse a single option
130 int parse_option( const string& arg );
132 // Parse the command line options
133 int parse_command_line( int argc, char **argv );
135 // Parse the command line options
136 int parse_config_file( const string& path );
138 // Print usage message
142 inline string get_fg_root() const { return fg_root; }
143 inline string get_airport_id() const { return airport_id; }
144 inline double get_lon() const { return lon; }
145 inline double get_lat() const { return lat; }
146 inline double get_altitude() const { return altitude; }
147 inline double get_heading() const { return heading; }
148 inline double get_roll() const { return roll; }
149 inline double get_pitch() const { return pitch; }
150 inline bool get_game_mode() const { return game_mode; }
151 inline bool get_splash_screen() const { return splash_screen; }
152 inline bool get_intro_music() const { return intro_music; }
153 inline int get_mouse_pointer() const { return mouse_pointer; }
154 inline bool get_pause() const { return pause; }
155 inline bool get_hud_status() const { return hud_status; }
156 inline bool get_panel_status() const { return panel_status; }
157 inline bool get_sound() const { return sound; }
158 inline int get_flight_model() const { return flight_model; }
159 inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
160 inline fgFogKind get_fog() const { return fog; }
161 inline double get_fov() const { return fov; }
162 inline bool get_fullscreen() const { return fullscreen; }
163 inline int get_shading() const { return shading; }
164 inline bool get_skyblend() const { return skyblend; }
165 inline bool get_textures() const { return textures; }
166 inline bool get_wireframe() const { return wireframe; }
167 inline int get_tile_radius() const { return tile_radius; }
168 inline int get_tile_diameter() const { return tile_diameter; }
169 inline int get_time_offset() const { return time_offset; }
170 inline int get_tris_or_culled() const { return tris_or_culled; }
173 inline void set_hud_status( bool status ) { hud_status = status; }
174 inline void set_fov( double amount ) { fov = amount; }
175 inline void set_textures( bool status ) { textures = status; }
176 inline void cycle_fog( void ) {
177 if ( fog == FG_FOG_DISABLED ) {
178 fog = FG_FOG_FASTEST;
179 } else if ( fog == FG_FOG_FASTEST ) {
181 xglHint ( GL_FOG_HINT, GL_NICEST );
182 } else if ( fog == FG_FOG_NICEST ) {
183 fog = FG_FOG_DISABLED;
184 xglHint ( GL_FOG_HINT, GL_FASTEST );
190 double parse_time( const string& time_str );
191 double parse_degree( const string& degree_str );
192 int parse_time_offset( const string& time_str );
193 int parse_tile_radius( const string& arg );
194 int parse_flight_model( const string& fm );
195 double parse_fov( const string& arg );
199 extern fgOPTIONS current_options;
202 #endif /* _OPTIONS_HXX */
206 // Revision 1.19 1998/10/25 14:08:49 curt
207 // Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
209 // Revision 1.18 1998/09/17 18:35:31 curt
210 // Added F8 to toggle fog and F9 to toggle texturing.
212 // Revision 1.17 1998/09/08 21:40:10 curt
213 // Fixes by Charlie Hotchkiss.
215 // Revision 1.16 1998/08/27 17:02:08 curt
216 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
217 // - use strings for fg_root and airport_id and added methods to return
219 // - inlined all access methods,
220 // - made the parsing functions private methods,
221 // - deleted some unused functions.
222 // - propogated some of these changes out a bit further.
224 // Revision 1.15 1998/08/24 20:11:15 curt
225 // Added i/I to toggle full vs. minimal HUD.
226 // Added a --hud-tris vs --hud-culled option.
227 // Moved options accessor funtions to options.hxx.
229 // Revision 1.14 1998/08/20 15:10:35 curt
230 // Added GameGLUT support.
232 // Revision 1.13 1998/07/30 23:48:29 curt
233 // Output position & orientation when pausing.
234 // Eliminated libtool use.
235 // Added options to specify initial position and orientation.
236 // Changed default fov to 55 degrees.
237 // Added command line option to start in paused or unpaused state.
239 // Revision 1.12 1998/07/27 18:41:26 curt
240 // Added a pause command "p"
241 // Fixed some initialization order problems between pui and glut.
242 // Added an --enable/disable-sound option.
244 // Revision 1.11 1998/07/13 21:01:39 curt
245 // Wrote access functions for current fgOPTIONS.
247 // Revision 1.10 1998/07/06 21:34:20 curt
248 // Added an enable/disable splash screen option.
249 // Added an enable/disable intro music option.
250 // Added an enable/disable instrument panel option.
251 // Added an enable/disable mouse pointer option.
252 // Added using namespace std for compilers that support this.
254 // Revision 1.9 1998/06/27 16:54:34 curt
255 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
256 // Don't change the view port when displaying the panel.
258 // Revision 1.8 1998/05/16 13:08:36 curt
259 // C++ - ified views.[ch]xx
260 // Shuffled some additional view parameters into the fgVIEW class.
261 // Changed tile-radius to tile-diameter because it is a much better
263 // Added a WORLD_TO_EYE transformation to views.cxx. This allows us
264 // to transform world space to eye space for view frustum culling.
266 // Revision 1.7 1998/05/13 18:29:59 curt
267 // Added a keyboard binding to dynamically adjust field of view.
268 // Added a command line option to specify fov.
269 // Adjusted terrain color.
270 // Root path info moved to fgOPTIONS.
271 // Added ability to parse options out of a config file.
273 // Revision 1.6 1998/05/06 03:16:26 curt
274 // Added an averaged global frame rate counter.
275 // Added an option to control tile radius.
277 // Revision 1.5 1998/05/03 00:47:32 curt
278 // Added an option to enable/disable full-screen mode.
280 // Revision 1.4 1998/04/30 12:34:19 curt
281 // Added command line rendering options:
282 // enable/disable fog/haze
283 // specify smooth/flat shading
284 // disable sky blending and just use a solid color
285 // enable wireframe drawing mode
287 // Revision 1.3 1998/04/28 01:20:23 curt
288 // Type-ified fgTIME and fgVIEW.
289 // Added a command line option to disable textures.
291 // Revision 1.2 1998/04/25 15:11:13 curt
292 // Added an command line option to set starting position based on airport ID.
294 // Revision 1.1 1998/04/24 00:49:21 curt
295 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
296 // Trying out some different option parsing code.
297 // Some code reorganization.