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