]> git.mxchange.org Git - flightgear.git/blob - Main/options.hxx
fbf9e80020efc1079e3f181518f5505a9c8ab36b
[flightgear.git] / Main / options.hxx
1 //
2 // options.hxx -- class to handle command line options
3 //
4 // Written by Curtis Olson, started April 1998.
5 //
6 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
7 //
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.
12 //
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.
17 //
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.
21 //
22 // $Id$
23 // (Log is kept at end of this file)
24
25
26 #ifndef _OPTIONS_HXX
27 #define _OPTIONS_HXX
28
29
30 #ifndef __cplusplus
31 # error This library requires C++
32 #endif                                   
33
34 #ifdef HAVE_CONFIG_H
35 #  include <config.h>
36 #endif
37
38 #ifdef HAVE_WINDOWS_H
39 #  include <windows.h>
40 #endif
41
42 #include <GL/glut.h>
43 #include <XGL/xgl.h>
44
45 #include <string>
46
47 #ifdef NEEDNAMESPACESTD
48 using namespace std;
49 #endif
50
51 class fgOPTIONS {
52 public:
53     enum
54     {
55         FG_OPTIONS_OK = 0,
56         FG_OPTIONS_HELP = 1,
57         FG_OPTIONS_ERROR = 2
58     };
59
60     enum fgFogKind
61     {
62         FG_FOG_DISABLED = 0,
63         FG_FOG_FASTEST  = 1,
64         FG_FOG_NICEST   = 2
65     };
66
67     static const int FG_RADIUS_MIN = 1;
68     static const int FG_RADIUS_MAX = 4;
69
70 private:
71
72     // The flight gear "root" directory
73     string fg_root;
74
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)
83
84     // Miscellaneous
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
90
91     // Features
92     bool hud_status;    // HUD on/off
93     bool panel_status;  // Panel on/off
94     bool sound;         // play sound effects
95
96     // Flight Model options
97     int flight_model;   // Flight Model:  FG_SLEW, FG_LARCSIM, etc.
98
99     // Rendering options
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
107
108     // Scenery options
109     int tile_radius;   // Square radius of rendered tiles (around center 
110                        // square.)
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 
114                        // further away.
115
116     // HUD options
117     int tris_or_culled;
118
119     // Time options
120     int time_offset;   // Offset true time by this many seconds
121
122 public:
123
124     fgOPTIONS();
125     ~fgOPTIONS();
126
127     // Parse a single option
128     int parse_option( const string& arg );
129
130     // Parse the command line options
131     int parse_command_line( int argc, char **argv );
132
133     // Parse the command line options
134     int parse_config_file( const string& path );
135
136     // Print usage message
137     void usage ( void );
138
139     // Query functions
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; }
169
170     // Update functions
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 ) {
178             fog = FG_FOG_NICEST;
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 );
183         }
184     }
185
186 private:
187
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 );
194 };
195
196
197 extern fgOPTIONS current_options;
198
199
200 #endif /* _OPTIONS_HXX */
201
202
203 // $Log$
204 // Revision 1.18  1998/09/17 18:35:31  curt
205 // Added F8 to toggle fog and F9 to toggle texturing.
206 //
207 // Revision 1.17  1998/09/08 21:40:10  curt
208 // Fixes by Charlie Hotchkiss.
209 //
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
213 //   them as strings,
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.
218 //
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.
223 //
224 // Revision 1.14  1998/08/20 15:10:35  curt
225 // Added GameGLUT support.
226 //
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.
233 //
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.
238 //
239 // Revision 1.11  1998/07/13 21:01:39  curt
240 // Wrote access functions for current fgOPTIONS.
241 //
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.
248 //
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.
252 //
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
257 //   name.
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.
260 //
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.
267 //
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.
271 //
272 // Revision 1.5  1998/05/03 00:47:32  curt
273 // Added an option to enable/disable full-screen mode.
274 //
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
281 //
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.
285 //
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.
288 //
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.
293 //
294 //