]> git.mxchange.org Git - flightgear.git/blob - Main/options.hxx
Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
[flightgear.git] / Main / options.hxx
1 // options.hxx -- class to handle command line options
2 //
3 // Written by Curtis Olson, started April 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifndef _OPTIONS_HXX
26 #define _OPTIONS_HXX
27
28
29 #ifndef __cplusplus
30 # error This library requires C++
31 #endif                                   
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <XGL/xgl.h>
43
44 #include <string>
45
46 #ifdef NEEDNAMESPACESTD
47 using namespace std;
48 #endif
49
50 #include "fg_serial.hxx"
51
52
53 class fgOPTIONS {
54
55 public:
56
57     enum
58     {
59         FG_OPTIONS_OK = 0,
60         FG_OPTIONS_HELP = 1,
61         FG_OPTIONS_ERROR = 2
62     };
63
64     enum
65     {
66         FG_UNITS_FEET = 0,
67         FG_UNITS_METERS = 1
68     };
69
70     enum fgFogKind
71     {
72         FG_FOG_DISABLED = 0,
73         FG_FOG_FASTEST  = 1,
74         FG_FOG_NICEST   = 2
75     };
76
77     static const int FG_RADIUS_MIN = 1;
78     static const int FG_RADIUS_MAX = 4;
79
80 private:
81
82     // The flight gear "root" directory
83     string fg_root;
84
85     // Starting position and orientation
86     string airport_id;  // ID of initial starting airport
87     double lon;         // starting longitude in degrees (west = -)
88     double lat;         // starting latitude in degrees (south = -)
89     double altitude;    // starting altitude in meters
90     double heading;     // heading (yaw) angle in degress (Psi)
91     double roll;        // roll angle in degrees (Phi)
92     double pitch;       // pitch angle in degrees (Theta)
93
94     // Miscellaneous
95     bool game_mode;     // Game mode enabled/disabled
96     bool splash_screen; // show splash screen
97     bool intro_music;   // play introductory music
98     int mouse_pointer;  // show mouse pointer
99     bool pause;         // pause intially enabled/disabled
100
101     // Features
102     bool hud_status;    // HUD on/off
103     bool panel_status;  // Panel on/off
104     bool sound;         // play sound effects
105
106     // Flight Model options
107     int flight_model;   // Flight Model:  FG_SLEW, FG_LARCSIM, etc.
108
109     // Rendering options
110     fgFogKind fog;      // Fog nicest/fastest/disabled
111     double fov;         // Field of View
112     bool fullscreen;    // Full screen mode enabled/disabled
113     int shading;        // shading method, 0 = Flat, 1 = Smooth
114     bool skyblend;      // Blend sky to haze (using polygons) or just clear
115     bool textures;      // Textures enabled/disabled
116     bool wireframe;     // Wireframe mode enabled/disabled
117     int xsize, ysize;   // window size derived from geometry string
118
119     // Scenery options
120     int tile_radius;   // Square radius of rendered tiles (around center 
121                        // square.)
122     int tile_diameter; // Diameter of rendered tiles.  for instance
123                        // if tile_diameter = 3 then a 3 x 3 grid of tiles will 
124                        // be drawn.  Increase this to see terrain that is 
125                        // further away.
126
127     // HUD options
128     int units;         // feet or meters
129     int tris_or_culled;
130
131     // Time options
132     int time_offset;   // Offset true time by this many seconds
133
134     // Serial Ports, we currently support up to four channels
135     // fgSerialPortKind port_a_kind;  // Port a kind
136     // fgSerialPortKind port_b_kind;  // Port b kind
137     // fgSerialPortKind port_c_kind;  // Port c kind
138     // fgSerialPortKind port_d_kind;  // Port d kind
139
140     // Serial port configuration strings
141     string port_a_config;
142     string port_b_config;
143     string port_c_config;
144     string port_d_config;
145     
146 public:
147
148     fgOPTIONS();
149     ~fgOPTIONS();
150
151     // Parse a single option
152     int parse_option( const string& arg );
153
154     // Parse the command line options
155     int parse_command_line( int argc, char **argv );
156
157     // Parse the command line options
158     int parse_config_file( const string& path );
159
160     // Print usage message
161     void usage ( void );
162
163     // Query functions
164     inline string get_fg_root() const { return fg_root; }
165     inline string get_airport_id() const { return airport_id; }
166     inline double get_lon() const { return lon; }
167     inline double get_lat() const { return lat; }
168     inline double get_altitude() const { return altitude; }
169     inline double get_heading() const { return heading; }
170     inline double get_roll() const { return roll; }
171     inline double get_pitch() const { return pitch; }
172     inline bool get_game_mode() const { return game_mode; }
173     inline bool get_splash_screen() const { return splash_screen; }
174     inline bool get_intro_music() const { return intro_music; }
175     inline int get_mouse_pointer() const { return mouse_pointer; }
176     inline bool get_pause() const { return pause; }
177     inline bool get_hud_status() const { return hud_status; }
178     inline bool get_panel_status() const { return panel_status; }
179     inline bool get_sound() const { return sound; }
180     inline int get_flight_model() const { return flight_model; }
181     inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
182     inline fgFogKind get_fog() const { return fog; }
183     inline double get_fov() const { return fov; }
184     inline bool get_fullscreen() const { return fullscreen; }
185     inline int get_shading() const { return shading; }
186     inline bool get_skyblend() const { return skyblend; }
187     inline bool get_textures() const { return textures; }
188     inline bool get_wireframe() const { return wireframe; }
189     inline int get_xsize() const { return xsize; }
190     inline int get_ysize() const { return ysize; }
191     inline int get_tile_radius() const { return tile_radius; }
192     inline int get_tile_diameter() const { return tile_diameter; }
193
194     inline int get_units() const { return units; }
195     inline int get_tris_or_culled() const { return tris_or_culled; }
196
197     inline int get_time_offset() const { return time_offset; }
198
199     // inline fgSerialPortKind get_port_a_kind() const { return port_a_kind; }
200     // inline fgSerialPortKind get_port_b_kind() const { return port_b_kind; }
201     // inline fgSerialPortKind get_port_c_kind() const { return port_c_kind; }
202     // inline fgSerialPortKind get_port_d_kind() const { return port_d_kind; }
203
204     inline string get_port_a_config() const { return port_a_config; }
205     inline string get_port_b_config() const { return port_b_config; }
206     inline string get_port_c_config() const { return port_c_config; }
207     inline string get_port_d_config() const { return port_d_config; }
208
209     // Update functions
210     inline void set_hud_status( bool status ) { hud_status = status; }
211     inline void set_fov( double amount ) { fov = amount; }
212     inline void set_textures( bool status ) { textures = status; }
213     inline void cycle_fog( void ) { 
214         if ( fog == FG_FOG_DISABLED ) {
215             fog = FG_FOG_FASTEST;
216         } else if ( fog == FG_FOG_FASTEST ) {
217             fog = FG_FOG_NICEST;
218             xglHint ( GL_FOG_HINT, GL_NICEST );
219         } else if ( fog == FG_FOG_NICEST ) {
220             fog = FG_FOG_DISABLED;
221             xglHint ( GL_FOG_HINT, GL_FASTEST );
222         }
223     }
224     inline void set_xsize( int x ) { xsize= x; }
225     inline void set_ysize( int y ) { xsize= y; }
226
227 private:
228
229     double parse_time( const string& time_str );
230     double parse_degree( const string& degree_str );
231     int parse_time_offset( const string& time_str );
232     int parse_tile_radius( const string& arg );
233     int parse_flight_model( const string& fm );
234     double parse_fov( const string& arg );
235     bool parse_serial( const string& serial_str );
236 };
237
238
239 extern fgOPTIONS current_options;
240
241
242 #endif /* _OPTIONS_HXX */
243
244
245 // $Log$
246 // Revision 1.22  1998/11/20 01:02:38  curt
247 // Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
248 //
249 // Revision 1.21  1998/11/16 14:00:04  curt
250 // Added pow() macro bug work around.
251 // Added support for starting FGFS at various resolutions.
252 // Added some initial serial port support.
253 // Specify default log levels in main().
254 //
255 // Revision 1.20  1998/11/02 23:04:05  curt
256 // HUD units now display in feet by default with meters being a command line
257 // option.
258 //
259 // Revision 1.19  1998/10/25 14:08:49  curt
260 // Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
261 //
262 // Revision 1.18  1998/09/17 18:35:31  curt
263 // Added F8 to toggle fog and F9 to toggle texturing.
264 //
265 // Revision 1.17  1998/09/08 21:40:10  curt
266 // Fixes by Charlie Hotchkiss.
267 //
268 // Revision 1.16  1998/08/27 17:02:08  curt
269 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
270 // - use strings for fg_root and airport_id and added methods to return
271 //   them as strings,
272 // - inlined all access methods,
273 // - made the parsing functions private methods,
274 // - deleted some unused functions.
275 // - propogated some of these changes out a bit further.
276 //
277 // Revision 1.15  1998/08/24 20:11:15  curt
278 // Added i/I to toggle full vs. minimal HUD.
279 // Added a --hud-tris vs --hud-culled option.
280 // Moved options accessor funtions to options.hxx.
281 //
282 // Revision 1.14  1998/08/20 15:10:35  curt
283 // Added GameGLUT support.
284 //
285 // Revision 1.13  1998/07/30 23:48:29  curt
286 // Output position & orientation when pausing.
287 // Eliminated libtool use.
288 // Added options to specify initial position and orientation.
289 // Changed default fov to 55 degrees.
290 // Added command line option to start in paused or unpaused state.
291 //
292 // Revision 1.12  1998/07/27 18:41:26  curt
293 // Added a pause command "p"
294 // Fixed some initialization order problems between pui and glut.
295 // Added an --enable/disable-sound option.
296 //
297 // Revision 1.11  1998/07/13 21:01:39  curt
298 // Wrote access functions for current fgOPTIONS.
299 //
300 // Revision 1.10  1998/07/06 21:34:20  curt
301 // Added an enable/disable splash screen option.
302 // Added an enable/disable intro music option.
303 // Added an enable/disable instrument panel option.
304 // Added an enable/disable mouse pointer option.
305 // Added using namespace std for compilers that support this.
306 //
307 // Revision 1.9  1998/06/27 16:54:34  curt
308 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
309 // Don't change the view port when displaying the panel.
310 //
311 // Revision 1.8  1998/05/16 13:08:36  curt
312 // C++ - ified views.[ch]xx
313 // Shuffled some additional view parameters into the fgVIEW class.
314 // Changed tile-radius to tile-diameter because it is a much better
315 //   name.
316 // Added a WORLD_TO_EYE transformation to views.cxx.  This allows us
317 //  to transform world space to eye space for view frustum culling.
318 //
319 // Revision 1.7  1998/05/13 18:29:59  curt
320 // Added a keyboard binding to dynamically adjust field of view.
321 // Added a command line option to specify fov.
322 // Adjusted terrain color.
323 // Root path info moved to fgOPTIONS.
324 // Added ability to parse options out of a config file.
325 //
326 // Revision 1.6  1998/05/06 03:16:26  curt
327 // Added an averaged global frame rate counter.
328 // Added an option to control tile radius.
329 //
330 // Revision 1.5  1998/05/03 00:47:32  curt
331 // Added an option to enable/disable full-screen mode.
332 //
333 // Revision 1.4  1998/04/30 12:34:19  curt
334 // Added command line rendering options:
335 //   enable/disable fog/haze
336 //   specify smooth/flat shading
337 //   disable sky blending and just use a solid color
338 //   enable wireframe drawing mode
339 //
340 // Revision 1.3  1998/04/28 01:20:23  curt
341 // Type-ified fgTIME and fgVIEW.
342 // Added a command line option to disable textures.
343 //
344 // Revision 1.2  1998/04/25 15:11:13  curt
345 // Added an command line option to set starting position based on airport ID.
346 //
347 // Revision 1.1  1998/04/24 00:49:21  curt
348 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
349 // Trying out some different option parsing code.
350 // Some code reorganization.
351 //
352 //