]> git.mxchange.org Git - flightgear.git/blob - src/Main/main.cxx
935bdd9cd0ab08c3f619292cca519591e506230a
[flightgear.git] / src / Main / main.cxx
1 // main.cxx -- top level sim routines
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997 - 2002  Curtis L. Olson  - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #include <simgear/compiler.h>
29
30 #if defined(__linux__) && defined(__i386__)
31 #  include <fpu_control.h>
32 #  include <signal.h>
33 #endif
34
35 #include <iostream>
36
37 #include <osg/Camera>
38 #include <osg/GraphicsContext>
39 #include <osgDB/Registry>
40
41 // Class references
42 #include <simgear/scene/model/modellib.hxx>
43 #include <simgear/scene/material/matlib.hxx>
44 #include <simgear/scene/model/animation.hxx>
45 #include <simgear/scene/sky/sky.hxx>
46 #include <simgear/structure/event_mgr.hxx>
47 #include <simgear/props/AtomicChangeListener.hxx>
48 #include <simgear/props/props.hxx>
49 #include <simgear/timing/sg_time.hxx>
50 #include <simgear/math/sg_random.h>
51
52 #include <Time/light.hxx>
53 #include <Include/general.hxx>
54 #include <Aircraft/replay.hxx>
55 #include <Cockpit/cockpit.hxx>
56 #include <Cockpit/hud.hxx>
57 #include <Model/panelnode.hxx>
58 #include <Model/modelmgr.hxx>
59 #include <Model/acmodel.hxx>
60 #include <Scenery/scenery.hxx>
61 #include <Scenery/tilemgr.hxx>
62 #include <Sound/fg_fx.hxx>
63 #include <Sound/beacon.hxx>
64 #include <Sound/morse.hxx>
65 #include <Sound/fg_fx.hxx>
66 #include <ATCDCL/ATCmgr.hxx>
67 #include <ATCDCL/AIMgr.hxx>
68 #include <Time/TimeManager.hxx>
69 #include <Environment/environment_mgr.hxx>
70 #include <Environment/ephemeris.hxx>
71 #include <GUI/new_gui.hxx>
72 #include <MultiPlayer/multiplaymgr.hxx>
73
74 #include "CameraGroup.hxx"
75 #include "fg_commands.hxx"
76 #include "fg_io.hxx"
77 #include "renderer.hxx"
78 #include "splash.hxx"
79 #include "main.hxx"
80 #include "util.hxx"
81 #include "fg_init.hxx"
82 #include "fg_os.hxx"
83 #include "WindowSystemAdapter.hxx"
84 #include <Main/viewer.hxx>
85
86
87 using namespace flightgear;
88
89 using std::cerr;
90
91 // This is a record containing a bit of global housekeeping information
92 FGGeneral general;
93
94 // Specify our current idle function state.  This is used to run all
95 // our initializations out of the idle callback so that we can get a
96 // splash screen up and running right away.
97 int idle_state = 0;
98
99
100 void fgInitSoundManager();
101 void fgSetNewSoundDevice(const char *);
102
103 // The atexit() function handler should know when the graphical subsystem
104 // is initialized.
105 extern int _bootstrap_OSInit;
106
107 // What should we do when we have nothing else to do?  Let's get ready
108 // for the next move and update the display?
109 static void fgMainLoop( void ) {
110     
111     static SGConstPropertyNode_ptr longitude
112         = fgGetNode("/position/longitude-deg");
113     static SGConstPropertyNode_ptr latitude
114         = fgGetNode("/position/latitude-deg");
115     static SGConstPropertyNode_ptr altitude
116         = fgGetNode("/position/altitude-ft");
117     static SGConstPropertyNode_ptr vn_fps
118         = fgGetNode("/velocities/speed-north-fps");
119     static SGConstPropertyNode_ptr ve_fps
120         = fgGetNode("/velocities/speed-east-fps");
121     static SGConstPropertyNode_ptr vd_fps
122         = fgGetNode("/velocities/speed-down-fps");
123       
124     static SGPropertyNode_ptr frame_signal
125         = fgGetNode("/sim/signals/frame", true);
126
127     frame_signal->fireValueChanged();
128     SGCloudLayer::enable_bump_mapping = fgGetBool("/sim/rendering/bump-mapping");
129     
130     SG_LOG( SG_ALL, SG_DEBUG, "Running Main Loop");
131     SG_LOG( SG_ALL, SG_DEBUG, "======= ==== ====");
132     
133     
134   // update "time"
135     double sim_dt, real_dt;
136     TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time");
137     // compute simulated time (allowing for pause, warp, etc) and
138     // real elapsed time
139     timeMgr->computeTimeDeltas(sim_dt, real_dt);
140     
141     if (globals->get_warp_delta() != 0) {
142         FGLight *l = (FGLight *)(globals->get_subsystem("lighting"));
143         l->update( 0.5 );
144     }
145
146     // update magvar model
147     globals->get_mag()->update( longitude->getDoubleValue()
148                                 * SGD_DEGREES_TO_RADIANS,
149                                 latitude->getDoubleValue()
150                                 * SGD_DEGREES_TO_RADIANS,
151                                 altitude->getDoubleValue() * SG_FEET_TO_METER,
152                                 globals->get_time_params()->getJD() );
153
154
155     // Update any multiplayer's network queues, the AIMultiplayer
156     // implementation is an AI model and depends on that
157     globals->get_multiplayer_mgr()->Update();
158
159 #if ENABLE_ATCDCL  
160     // Run ATC subsystem
161     if (fgGetBool("/sim/atc/enabled"))
162         globals->get_ATC_mgr()->update(sim_dt);
163
164
165     // Run the AI subsystem
166     // NOTE: the AI_mgr has nothing to do with the AIModels subsystem.
167     // There was previously a comment here stating that the
168     // AI_mgr code should be run then multiplayer is enabled.
169     // Multiplayer relies on AIModels, and not on the old and
170     // depricated AI_mgr system. So, we can safely skip the following
171     // two lines at compile time when compiling with --disable-atcdcl
172     if (fgGetBool("/sim/ai-traffic/enabled"))
173         globals->get_AI_mgr()->update(sim_dt);
174 #endif  
175     
176     globals->get_subsystem_mgr()->update(sim_dt);
177     globals->get_aircraft_model()->update(sim_dt);
178     
179     //
180     // Tile Manager updates - see if we need to load any new scenery tiles.
181     //   this code ties together the fdm, viewer and scenery classes...
182     //   we may want to move this to its own class at some point
183     //
184     double visibility_meters = fgGetDouble("/environment/visibility-m");
185     globals->get_tile_mgr()->prep_ssg_nodes( visibility_meters );
186
187     // update tile manager for view...
188     SGVec3d viewPos = globals->get_current_view()->get_view_pos();
189     SGGeod geodViewPos = SGGeod::fromCart(viewPos);
190     globals->get_tile_mgr()->update(geodViewPos, visibility_meters);
191
192     // run Nasal's settimer() loops right before the view manager
193     globals->get_event_mgr()->update(sim_dt);
194
195     // pick up model coordidnates that Nasal code may have set relative to the
196     // aircraft's
197     globals->get_model_mgr()->update(sim_dt);
198
199     // update the view angle as late as possible, but before sound calculations
200     globals->get_viewmgr()->update(real_dt);
201
202     // Update the sound manager last so it can use the CPU while the GPU
203     // is processing the scenery (doubled the frame-rate for me) -EMH-
204 #ifdef ENABLE_AUDIO_SUPPORT
205     static bool smgr_init = true;
206     static SGPropertyNode *sound_working = fgGetNode("/sim/sound/working");
207     if (smgr_init == true) {
208         if (sound_working->getBoolValue() == true) {
209             fgInitSoundManager();
210             smgr_init = false;
211         }
212     } else {
213         static SGPropertyNode *sound_enabled = fgGetNode("/sim/sound/enabled");
214         static SGSoundMgr *smgr = globals->get_soundmgr();
215         static bool smgr_enabled = true;
216
217         if (sound_working->getBoolValue() == false) {   // request to reinit
218            smgr->reinit();
219            smgr->resume();
220            sound_working->setBoolValue(true);
221         }
222
223         if (smgr_enabled != sound_enabled->getBoolValue()) {
224             if (smgr_enabled == true) { // request to suspend
225                 smgr->suspend();
226                 smgr_enabled = false;
227             } else {
228                 smgr->resume();
229                 smgr_enabled = true;
230             }
231         }
232
233         if (smgr_enabled == true) {
234             static SGPropertyNode *volume = fgGetNode("/sim/sound/volume");
235             smgr->set_volume(volume->getFloatValue());
236             smgr->update(sim_dt);
237         }
238     }
239 #endif
240
241     // END Tile Manager udpates
242     bool scenery_loaded = fgGetBool("sim/sceneryloaded");
243     if (!scenery_loaded && globals->get_tile_mgr()->isSceneryLoaded()
244         && fgGetBool("sim/fdm-initialized")) {
245         fgSetBool("sim/sceneryloaded",true);
246         if (fgGetBool("/sim/sound/working")) {
247             globals->get_soundmgr()->activate();
248         }
249         globals->get_props()->tie("/sim/sound/devices/name",
250               SGRawValueFunctions<const char *>(0, fgSetNewSoundDevice), false);
251     }
252     simgear::AtomicChangeListener::fireChangeListeners();
253     fgRequestRedraw();
254
255     SG_LOG( SG_ALL, SG_DEBUG, "" );
256 }
257
258 void fgInitSoundManager()
259 {
260     SGSoundMgr *smgr = globals->get_soundmgr();
261
262     smgr->bind();
263     smgr->init(fgGetString("/sim/sound/device-name", NULL));
264
265     vector <const char*>devices = smgr->get_available_devices();
266     for (unsigned int i=0; i<devices.size(); i++) {
267         SGPropertyNode *p = fgGetNode("/sim/sound/devices/device", i, true);
268         p->setStringValue(devices[i]);
269     }
270     devices.clear();
271 }
272
273 void fgSetNewSoundDevice(const char *device)
274 {
275     globals->get_soundmgr()->suspend();
276     globals->get_soundmgr()->stop();
277     globals->get_soundmgr()->init(device);
278     globals->get_soundmgr()->resume();
279 }
280
281 // Operation for querying OpenGL parameters. This must be done in a
282 // valid OpenGL context, potentially in another thread.
283 namespace
284 {
285 struct GeneralInitOperation : public GraphicsContextOperation
286 {
287     GeneralInitOperation()
288         : GraphicsContextOperation(std::string("General init"))
289     {
290     }
291     void run(osg::GraphicsContext* gc)
292     {
293         general.set_glVendor( (char *)glGetString ( GL_VENDOR ) );
294         general.set_glRenderer( (char *)glGetString ( GL_RENDERER ) );
295         general.set_glVersion( (char *)glGetString ( GL_VERSION ) );
296         SG_LOG( SG_GENERAL, SG_INFO, general.get_glVendor() );
297         SG_LOG( SG_GENERAL, SG_INFO, general.get_glRenderer() );
298         SG_LOG( SG_GENERAL, SG_INFO, general.get_glVersion() );
299
300         GLint tmp;
301         glGetIntegerv( GL_MAX_TEXTURE_SIZE, &tmp );
302         general.set_glMaxTexSize( tmp );
303         SG_LOG ( SG_GENERAL, SG_INFO, "Max texture size = " << tmp );
304
305         glGetIntegerv( GL_DEPTH_BITS, &tmp );
306         general.set_glDepthBits( tmp );
307         SG_LOG ( SG_GENERAL, SG_INFO, "Depth buffer bits = " << tmp );
308     }
309 };
310
311
312 osg::Node* load_panel(SGPropertyNode *n)
313 {
314     osg::Geode* geode = new osg::Geode;
315     geode->addDrawable(new FGPanelNode(n));
316     return geode;
317 }
318
319 SGPath resolve_path(const std::string& s)
320 {
321   return globals->resolve_maybe_aircraft_path(s);
322 }
323
324 }
325
326 // This is the top level master main function that is registered as
327 // our idle funciton
328
329 // The first few passes take care of initialization things (a couple
330 // per pass) and once everything has been initialized fgMainLoop from
331 // then on.
332
333 static void fgIdleFunction ( void ) {
334     static osg::ref_ptr<GeneralInitOperation> genOp;
335     if ( idle_state == 0 ) {
336         idle_state++;
337         // Pick some window on which to do queries.
338         // XXX Perhaps all this graphics initialization code should be
339         // moved to renderer.cxx?
340         genOp = new GeneralInitOperation;
341         osg::Camera* guiCamera = getGUICamera(CameraGroup::getDefault());
342         WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
343         osg::GraphicsContext* gc = 0;
344         if (guiCamera)
345             gc = guiCamera->getGraphicsContext();
346         if (gc) {
347             gc->add(genOp.get());
348         } else {
349             wsa->windows[0]->gc->add(genOp.get());
350         }
351         guiStartInit(gc);
352     } else if ( idle_state == 1 ) {
353         if (genOp.valid()) {
354             if (!genOp->isFinished())
355                 return;
356             genOp = 0;
357         }
358         if (!guiFinishInit())
359             return;
360         idle_state++;
361         fgSplashProgress("reading aircraft list");
362
363
364     } else if ( idle_state == 2 ) {
365         idle_state++;
366                 
367         fgSplashProgress("reading airport & navigation data");
368
369
370     } else if ( idle_state == 3 ) {
371         idle_state++;
372         fgInitNav();
373         fgSplashProgress("setting up scenery");
374
375
376     } else if ( idle_state == 4 ) {
377         idle_state++;
378         // based on the requested presets, calculate the true starting
379         // lon, lat
380         fgInitPosition();
381         fgInitTowerLocationListener();
382
383         TimeManager* t = new TimeManager;
384         globals->add_subsystem("time", t, SGSubsystemMgr::INIT);
385         t->init(); // need to init now, not during initSubsystems
386         
387         // Do some quick general initializations
388         if( !fgInitGeneral()) {
389             SG_LOG( SG_GENERAL, SG_ALERT,
390                 "General initialization failed ..." );
391             exit(-1);
392         }
393
394         ////////////////////////////////////////////////////////////////////
395         // Initialize the property-based built-in commands
396         ////////////////////////////////////////////////////////////////////
397         fgInitCommands();
398
399
400         ////////////////////////////////////////////////////////////////////
401         // Initialize the material manager
402         ////////////////////////////////////////////////////////////////////
403         globals->set_matlib( new SGMaterialLib );
404         simgear::SGModelLib::init(globals->get_fg_root());
405         simgear::SGModelLib::setPropRoot(globals->get_props());
406         simgear::SGModelLib::setResolveFunc(resolve_path);
407         simgear::SGModelLib::setPanelFunc(load_panel);
408         
409         ////////////////////////////////////////////////////////////////////
410         // Initialize the TG scenery subsystem.
411         ////////////////////////////////////////////////////////////////////
412         globals->set_scenery( new FGScenery );
413         globals->get_scenery()->init();
414         globals->get_scenery()->bind();
415         globals->set_tile_mgr( new FGTileMgr );
416
417
418         ////////////////////////////////////////////////////////////////////
419         // Initialize the general model subsystem.
420         ////////////////////////////////////////////////////////////////////
421         globals->set_model_mgr(new FGModelMgr);
422         globals->get_model_mgr()->init();
423         globals->get_model_mgr()->bind();
424         fgSplashProgress("loading aircraft");
425
426
427     } else if ( idle_state == 5 ) {
428         idle_state++;
429
430         ////////////////////////////////////////////////////////////////////
431         // Initialize the 3D aircraft model subsystem (has a dependency on
432         // the scenery subsystem.)
433         ////////////////////////////////////////////////////////////////////
434         FGAircraftModel* acm = new FGAircraftModel;
435         globals->set_aircraft_model(acm);
436         //globals->add_subsystem("aircraft-model", acm);
437         acm->init();
438         acm->bind();
439
440         ////////////////////////////////////////////////////////////////////
441         // Initialize the view manager subsystem.
442         ////////////////////////////////////////////////////////////////////
443         FGViewMgr *viewmgr = new FGViewMgr;
444         globals->set_viewmgr( viewmgr );
445         viewmgr->init();
446         viewmgr->bind();
447         fgSplashProgress("generating sky elements");
448
449
450     } else if ( idle_state == 6 ) {
451         idle_state++;
452         // Initialize the sky
453
454         Ephemeris* eph = new Ephemeris;
455         globals->add_subsystem("ephmeris", eph);
456         eph->init(); // FIXME - remove this once SGSky code below is also a subsystem
457         eph->bind();
458
459         // TODO: move to environment mgr
460         thesky = new SGSky;
461         SGPath texture_path(globals->get_fg_root());
462         texture_path.append("Textures");
463         texture_path.append("Sky");
464         for (int i = 0; i < FGEnvironmentMgr::MAX_CLOUD_LAYERS; i++) {
465             SGCloudLayer * layer = new SGCloudLayer(texture_path.str());
466             thesky->add_cloud_layer(layer);
467         }
468
469         SGPath sky_tex_path( globals->get_fg_root() );
470         sky_tex_path.append( "Textures" );
471         sky_tex_path.append( "Sky" );
472         thesky->texture_path( sky_tex_path.str() );
473
474         // The sun and moon diameters are scaled down numbers of the
475         // actual diameters. This was needed to fit both the sun and the
476         // moon within the distance to the far clip plane.
477         // Moon diameter:    3,476 kilometers
478         // Sun diameter: 1,390,000 kilometers
479         thesky->build( 80000.0, 80000.0,
480                        463.3, 361.8,
481                        *globals->get_ephem(),
482                        fgGetNode("/environment", true));
483
484         // Initialize MagVar model
485         SGMagVar *magvar = new SGMagVar();
486         globals->set_mag( magvar );
487
488
489                                     // kludge to initialize mag compass
490                                     // (should only be done for in-flight
491                                     // startup)
492         // update magvar model
493         globals->get_mag()->update( fgGetDouble("/position/longitude-deg")
494                                     * SGD_DEGREES_TO_RADIANS,
495                                     fgGetDouble("/position/latitude-deg")
496                                     * SGD_DEGREES_TO_RADIANS,
497                                     fgGetDouble("/position/altitude-ft")
498                                     * SG_FEET_TO_METER,
499                                     globals->get_time_params()->getJD() );
500         double var = globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
501         fgSetDouble("/instrumentation/heading-indicator/offset-deg", -var);
502         fgSetDouble("/instrumentation/heading-indicator-fg/offset-deg", -var);
503
504
505         // airport = new ssgBranch;
506         // airport->setName( "Airport Lighting" );
507         // lighting->addKid( airport );
508
509         // build our custom render states
510         fgSplashProgress("initializing subsystems");
511
512
513     } else if ( idle_state == 7 ) {
514         idle_state++;
515         // Initialize audio support
516 #ifdef ENABLE_AUDIO_SUPPORT
517
518         // Start the intro music
519         if ( fgGetBool("/sim/startup/intro-music") ) {
520             SGPath mp3file( globals->get_fg_root() );
521             mp3file.append( "Sounds/intro.mp3" );
522
523             SG_LOG( SG_GENERAL, SG_INFO,
524                 "Starting intro music: " << mp3file.str() );
525
526 # if defined( __CYGWIN__ )
527             string command = "start /m `cygpath -w " + mp3file.str() + "`";
528 # elif defined( _WIN32 )
529             string command = "start /m " + mp3file.str();
530 # else
531             string command = "mpg123 " + mp3file.str() + "> /dev/null 2>&1";
532 # endif
533
534             system ( command.c_str() );
535         }
536 #endif
537         // This is the top level init routine which calls all the
538         // other subsystem initialization routines.  If you are adding
539         // a subsystem to flightgear, its initialization call should be
540         // located in this routine.
541         if( !fgInitSubsystems()) {
542             SG_LOG( SG_GENERAL, SG_ALERT,
543                 "Subsystem initialization failed ..." );
544             exit(-1);
545         }
546         fgSplashProgress("setting up time & renderer");
547
548
549     } else if ( idle_state == 8 ) {
550         idle_state = 1000;
551         
552         // setup OpenGL view parameters
553         globals->get_renderer()->init();
554
555         globals->get_renderer()->resize( fgGetInt("/sim/startup/xsize"),
556                                          fgGetInt("/sim/startup/ysize") );
557
558         fgSplashProgress("loading scenery objects");
559         int session = fgGetInt("/sim/session",0);
560         session++;
561         fgSetInt("/sim/session",session);
562     }
563
564     if ( idle_state == 1000 ) {
565         // We've finished all our initialization steps, from now on we
566         // run the main loop.
567         fgSetBool("sim/sceneryloaded", false);
568         fgRegisterIdleHandler( fgMainLoop );
569     }
570 }
571
572
573 static void upper_case_property(const char *name)
574 {
575     using namespace simgear;
576     SGPropertyNode *p = fgGetNode(name, false);
577     if (!p) {
578         p = fgGetNode(name, true);
579         p->setStringValue("");
580     } else {
581         props::Type t = p->getType();
582         if (t == props::NONE || t == props::UNSPECIFIED)
583             p->setStringValue("");
584         else
585             assert(t == props::STRING);
586     }
587     p->addChangeListener(new FGMakeUpperCase);
588 }
589
590
591 // Main top level initialization
592 bool fgMainInit( int argc, char **argv ) {
593
594     // set default log levels
595     sglog().setLogLevels( SG_ALL, SG_ALERT );
596
597     string version;
598 #ifdef FLIGHTGEAR_VERSION
599     version = FLIGHTGEAR_VERSION;
600 #else
601     version = "unknown version";
602 #endif
603     SG_LOG( SG_GENERAL, SG_INFO, "FlightGear:  Version "
604             << version );
605     SG_LOG( SG_GENERAL, SG_INFO, "Built with " << SG_COMPILER_STR << endl );
606
607     // Allocate global data structures.  This needs to happen before
608     // we parse command line options
609
610     globals = new FGGlobals;
611
612     // seed the random number generator
613     sg_srandom_time();
614
615     FGControls *controls = new FGControls;
616     globals->set_controls( controls );
617
618     string_list *col = new string_list;
619     globals->set_channel_options_list( col );
620
621     fgValidatePath("", false);  // initialize static variables
622     upper_case_property("/sim/presets/airport-id");
623     upper_case_property("/sim/presets/runway");
624     upper_case_property("/sim/tower/airport-id");
625     upper_case_property("/autopilot/route-manager/input");
626
627     // Scan the config file(s) and command line options to see if
628     // fg_root was specified (ignore all other options for now)
629     fgInitFGRoot(argc, argv);
630
631     // Check for the correct base package version
632     static char required_version[] = "2.0.0";
633     string base_version = fgBasePackageVersion();
634     if ( !(base_version == required_version) ) {
635         // tell the operator how to use this application
636
637         SG_LOG( SG_GENERAL, SG_ALERT, "" ); // To popup the console on windows
638         cerr << endl << "Base package check failed ... " \
639              << "Found version " << base_version << " at: " \
640              << globals->get_fg_root() << endl;
641         cerr << "Please upgrade to version: " << required_version << endl;
642 #ifdef _MSC_VER
643         cerr << "Hit a key to continue..." << endl;
644         cin.get();
645 #endif
646         exit(-1);
647     }
648
649     // Load the configuration parameters.  (Command line options
650     // override config file options.  Config file options override
651     // defaults.)
652     if ( !fgInitConfig(argc, argv) ) {
653         SG_LOG( SG_GENERAL, SG_ALERT, "Config option parsing failed ..." );
654         exit(-1);
655     }
656
657     // Initialize the Window/Graphics environment.
658     fgOSInit(&argc, argv);
659     _bootstrap_OSInit++;
660
661     fgRegisterWindowResizeHandler( &FGRenderer::resize );
662     fgRegisterIdleHandler( &fgIdleFunction );
663     fgRegisterDrawHandler( &FGRenderer::update );
664
665     // Initialize plib net interface
666     netInit( &argc, argv );
667
668     // Clouds3D requires an alpha channel
669     fgOSOpenWindow(true /* request stencil buffer */);
670
671     // Initialize the splash screen right away
672     fntInit();
673     fgSplashInit();
674
675     // pass control off to the master event handler
676     fgOSMainLoop();
677
678     // we never actually get here ... but to avoid compiler warnings,
679     // etc.
680     return false;
681 }
682
683