1999-06-18 03:42:54 +00:00
|
|
|
// main.cxx -- top level sim routines
|
1998-04-21 17:02:27 +00:00
|
|
|
//
|
2002-04-05 00:38:55 +00:00
|
|
|
// Written by Curtis Olson, started May 1997.
|
1998-04-21 17:02:27 +00:00
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 1997 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
|
1998-04-21 17:02:27 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1998-04-21 17:02:27 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
1999-06-18 03:42:54 +00:00
|
|
|
|
1998-04-24 00:49:17 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
1998-04-21 17:02:27 +00:00
|
|
|
|
2003-08-17 09:54:41 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2008-08-01 15:57:29 +00:00
|
|
|
#include <osg/Camera>
|
|
|
|
#include <osg/GraphicsContext>
|
2008-03-22 09:31:06 +00:00
|
|
|
#include <osgDB/Registry>
|
|
|
|
|
2005-03-09 21:56:00 +00:00
|
|
|
// Class references
|
2012-10-31 00:40:43 +00:00
|
|
|
#include <simgear/canvas/VGInitOperation.hxx>
|
2003-05-15 21:35:51 +00:00
|
|
|
#include <simgear/scene/model/modellib.hxx>
|
2004-09-20 13:21:51 +00:00
|
|
|
#include <simgear/scene/material/matlib.hxx>
|
2009-11-03 11:41:00 +00:00
|
|
|
#include <simgear/props/AtomicChangeListener.hxx>
|
2008-07-31 12:04:32 +00:00
|
|
|
#include <simgear/props/props.hxx>
|
2010-12-26 23:19:57 +00:00
|
|
|
#include <simgear/timing/sg_time.hxx>
|
2010-10-23 19:37:26 +00:00
|
|
|
#include <simgear/io/raw_socket.hxx>
|
2011-06-11 22:44:07 +00:00
|
|
|
#include <simgear/scene/tsync/terrasync.hxx>
|
2012-05-12 21:27:57 +00:00
|
|
|
#include <simgear/math/SGMath.hxx>
|
|
|
|
#include <simgear/math/sg_random.h>
|
2008-07-31 12:04:32 +00:00
|
|
|
|
2003-08-17 09:54:41 +00:00
|
|
|
#include <Model/panelnode.hxx>
|
|
|
|
#include <Scenery/scenery.hxx>
|
|
|
|
#include <Scenery/tilemgr.hxx>
|
2012-09-17 11:36:38 +00:00
|
|
|
#include <Sound/soundmanager.hxx>
|
2010-07-13 20:50:44 +00:00
|
|
|
#include <Time/TimeManager.hxx>
|
2010-12-26 23:19:57 +00:00
|
|
|
#include <GUI/gui.h>
|
2012-04-25 21:28:00 +00:00
|
|
|
#include <Viewer/splash.hxx>
|
|
|
|
#include <Viewer/renderer.hxx>
|
2012-10-31 00:40:43 +00:00
|
|
|
#include <Viewer/WindowSystemAdapter.hxx>
|
2012-08-27 23:26:36 +00:00
|
|
|
#include <Navaids/NavDataCache.hxx>
|
2004-09-20 13:21:51 +00:00
|
|
|
|
Andy Ross:
The biggest and coolest patch adds mouse sensitivity to the 3D
cockpits, so we can finally work the radios. This ended up requiring
significant modifications outside of the 3D cockpit code. Stuff folks
will want to look at:
+ The list of all "3D" cockpits is stored statically in the
panelnode.cxx file. This is clumsy, and won't migrate well to a
multiple-aircraft feature. Really, there should be a per-model list
of 3D panels, but I couldn't find a clean place to put this. The
only handle you get back after parsing a model is a generic ssg
node, to which I obviously can't add panel-specific methods.
+ The aircraft model is parsed *very* early in the initialization
order. Earlier, in fact, than the static list of allowable command
bindings is built in fgInitCommands(). This is bad, as it means
that mouse bindings on the instruments can't work yet. I moved the
call to fgInitCommands, but someone should look carefully to see
that I picked the right place. There's a lot of initialization
code, and I got a little lost in there... :)
+ I added yet another "update" hook to the fgRenderFrame routine to
hook the updates for the 3D panels. This is only required for
"mouse press delay", and it's a fairly clumsy mechanism based on
frame rate instead of real time. There appears to be delay handling
already in place in the Input stuff, and there's a discussion going
on about different mouse behavior right now. Maybe this is a good
time to unify these two (now three) approaches?
2002-10-29 19:44:03 +00:00
|
|
|
#include "fg_commands.hxx"
|
2003-08-17 09:54:41 +00:00
|
|
|
#include "fg_io.hxx"
|
2003-08-29 16:46:21 +00:00
|
|
|
#include "main.hxx"
|
2008-07-11 16:36:54 +00:00
|
|
|
#include "util.hxx"
|
2008-07-29 08:27:48 +00:00
|
|
|
#include "fg_init.hxx"
|
2009-08-05 14:29:32 +00:00
|
|
|
#include "fg_os.hxx"
|
2012-04-25 21:28:00 +00:00
|
|
|
#include "fg_props.hxx"
|
2012-09-18 19:50:28 +00:00
|
|
|
#include "positioninit.hxx"
|
2012-09-30 15:34:51 +00:00
|
|
|
#include "subsystemFactory.hxx"
|
2003-08-29 16:46:21 +00:00
|
|
|
|
2008-08-01 15:57:29 +00:00
|
|
|
using namespace flightgear;
|
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
using std::cerr;
|
2012-05-12 21:27:57 +00:00
|
|
|
using std::vector;
|
2008-08-14 18:13:39 +00:00
|
|
|
|
2006-08-07 15:16:46 +00:00
|
|
|
// The atexit() function handler should know when the graphical subsystem
|
2004-08-24 08:40:41 +00:00
|
|
|
// is initialized.
|
|
|
|
extern int _bootstrap_OSInit;
|
|
|
|
|
2011-11-20 15:20:05 +00:00
|
|
|
// What should we do when we have nothing else to do? Let's get ready
|
|
|
|
// for the next move and update the display?
|
|
|
|
static void fgMainLoop( void )
|
2010-01-10 11:00:52 +00:00
|
|
|
{
|
2011-11-20 15:20:05 +00:00
|
|
|
static SGPropertyNode_ptr frame_signal
|
|
|
|
= fgGetNode("/sim/signals/frame", true);
|
2010-01-10 11:00:52 +00:00
|
|
|
|
2011-11-20 15:20:05 +00:00
|
|
|
frame_signal->fireValueChanged();
|
2010-01-10 11:00:52 +00:00
|
|
|
|
2011-11-20 15:20:05 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_DEBUG, "Running Main Loop");
|
|
|
|
SG_LOG( SG_GENERAL, SG_DEBUG, "======= ==== ====");
|
2010-01-10 11:00:52 +00:00
|
|
|
|
2011-11-20 15:20:05 +00:00
|
|
|
// compute simulated time (allowing for pause, warp, etc) and
|
|
|
|
// real elapsed time
|
|
|
|
double sim_dt, real_dt;
|
2012-09-17 11:41:42 +00:00
|
|
|
static TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time");
|
2011-11-20 15:20:05 +00:00
|
|
|
timeMgr->computeTimeDeltas(sim_dt, real_dt);
|
|
|
|
|
|
|
|
// update all subsystems
|
|
|
|
globals->get_subsystem_mgr()->update(sim_dt);
|
|
|
|
|
|
|
|
simgear::AtomicChangeListener::fireChangeListeners();
|
|
|
|
|
|
|
|
SG_LOG( SG_GENERAL, SG_DEBUG, "" );
|
2009-11-30 14:24:16 +00:00
|
|
|
}
|
|
|
|
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2008-08-01 15:57:29 +00:00
|
|
|
// This is the top level master main function that is registered as
|
2011-05-22 16:28:42 +00:00
|
|
|
// our idle function
|
2007-04-29 09:58:37 +00:00
|
|
|
|
2008-08-01 15:57:29 +00:00
|
|
|
// The first few passes take care of initialization things (a couple
|
|
|
|
// per pass) and once everything has been initialized fgMainLoop from
|
|
|
|
// then on.
|
2007-04-29 09:58:37 +00:00
|
|
|
|
2008-08-01 15:57:29 +00:00
|
|
|
static void fgIdleFunction ( void ) {
|
2012-09-17 11:41:42 +00:00
|
|
|
// Specify our current idle function state. This is used to run all
|
|
|
|
// our initializations out of the idle callback so that we can get a
|
|
|
|
// splash screen up and running right away.
|
|
|
|
static int idle_state = 0;
|
2012-09-18 19:29:36 +00:00
|
|
|
|
2008-08-01 15:57:29 +00:00
|
|
|
if ( idle_state == 0 ) {
|
2012-09-25 20:39:13 +00:00
|
|
|
if (guiInit())
|
|
|
|
{
|
|
|
|
idle_state+=2;
|
|
|
|
fgSplashProgress("loading-aircraft-list");
|
2008-08-01 15:57:29 +00:00
|
|
|
}
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
} else if ( idle_state == 2 ) {
|
2005-05-04 21:28:42 +00:00
|
|
|
idle_state++;
|
2012-09-26 12:38:26 +00:00
|
|
|
fgSplashProgress("loading-nav-dat");
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
} else if ( idle_state == 3 ) {
|
2012-09-25 16:24:12 +00:00
|
|
|
|
|
|
|
bool done = fgInitNav();
|
|
|
|
if (done) {
|
|
|
|
++idle_state;
|
|
|
|
fgSplashProgress("init-scenery");
|
|
|
|
} else {
|
2012-09-26 12:38:26 +00:00
|
|
|
fgSplashProgress("loading-nav-dat");
|
2012-09-25 16:24:12 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
} else if ( idle_state == 4 ) {
|
2012-09-17 11:41:42 +00:00
|
|
|
idle_state+=2;
|
2005-05-04 21:28:42 +00:00
|
|
|
// based on the requested presets, calculate the true starting
|
|
|
|
// lon, lat
|
2012-09-18 19:50:28 +00:00
|
|
|
flightgear::initPosition();
|
|
|
|
flightgear::initTowerLocationListener();
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2010-07-13 20:50:44 +00:00
|
|
|
TimeManager* t = new TimeManager;
|
|
|
|
globals->add_subsystem("time", t, SGSubsystemMgr::INIT);
|
|
|
|
t->init(); // need to init now, not during initSubsystems
|
|
|
|
|
2005-05-04 21:28:42 +00:00
|
|
|
// Do some quick general initializations
|
|
|
|
if( !fgInitGeneral()) {
|
2006-08-07 15:16:46 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
|
|
|
"General initialization failed ..." );
|
2005-05-04 21:28:42 +00:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
// Initialize the property-based built-in commands
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
fgInitCommands();
|
|
|
|
|
2012-09-30 15:34:51 +00:00
|
|
|
flightgear::registerSubsystemCommands(globals->get_commands());
|
|
|
|
|
2005-05-04 21:28:42 +00:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
// Initialize the material manager
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
globals->set_matlib( new SGMaterialLib );
|
2011-04-03 17:13:51 +00:00
|
|
|
simgear::SGModelLib::init(globals->get_fg_root(), globals->get_props());
|
2012-01-02 23:16:18 +00:00
|
|
|
simgear::SGModelLib::setPanelFunc(FGPanelNode::load);
|
2011-05-22 16:28:42 +00:00
|
|
|
|
2005-05-04 21:28:42 +00:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
// Initialize the TG scenery subsystem.
|
|
|
|
////////////////////////////////////////////////////////////////////
|
2011-06-11 22:44:07 +00:00
|
|
|
simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props());
|
|
|
|
globals->add_subsystem("terrasync", terra_sync);
|
2005-05-04 21:28:42 +00:00
|
|
|
globals->set_scenery( new FGScenery );
|
|
|
|
globals->get_scenery()->init();
|
|
|
|
globals->get_scenery()->bind();
|
|
|
|
globals->set_tile_mgr( new FGTileMgr );
|
|
|
|
|
2012-09-21 17:36:25 +00:00
|
|
|
fgSplashProgress("loading-aircraft");
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
} else if ( idle_state == 6 ) {
|
2005-05-04 21:28:42 +00:00
|
|
|
idle_state++;
|
2012-09-21 17:36:25 +00:00
|
|
|
fgSplashProgress("creating-subsystems");
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
} else if ( idle_state == 7 ) {
|
2005-05-04 21:28:42 +00:00
|
|
|
idle_state++;
|
2012-09-18 19:29:36 +00:00
|
|
|
SGTimeStamp st;
|
|
|
|
st.stamp();
|
|
|
|
fgCreateSubsystems();
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Creating subsystems took:" << st.elapsedMSec());
|
2012-09-21 17:36:25 +00:00
|
|
|
fgSplashProgress("binding-subsystems");
|
2012-09-18 19:29:36 +00:00
|
|
|
|
|
|
|
} else if ( idle_state == 8 ) {
|
|
|
|
idle_state++;
|
|
|
|
SGTimeStamp st;
|
|
|
|
st.stamp();
|
|
|
|
globals->get_subsystem_mgr()->bind();
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Binding subsystems took:" << st.elapsedMSec());
|
|
|
|
|
2012-09-21 17:36:25 +00:00
|
|
|
fgSplashProgress("init-subsystems");
|
2012-09-18 19:29:36 +00:00
|
|
|
} else if ( idle_state == 9 ) {
|
|
|
|
SGSubsystem::InitStatus status = globals->get_subsystem_mgr()->incrementalInit();
|
|
|
|
if ( status == SGSubsystem::INIT_DONE) {
|
|
|
|
++idle_state;
|
2012-09-21 17:36:25 +00:00
|
|
|
fgSplashProgress("finishing-subsystems");
|
2012-09-18 19:29:36 +00:00
|
|
|
} else {
|
2012-09-21 17:36:25 +00:00
|
|
|
fgSplashProgress("init-subsystems");
|
2003-04-15 14:10:47 +00:00
|
|
|
}
|
2012-09-18 19:29:36 +00:00
|
|
|
|
|
|
|
} else if ( idle_state == 10 ) {
|
|
|
|
idle_state = 900;
|
|
|
|
fgPostInitSubsystems();
|
|
|
|
|
|
|
|
// Torsten Dreyer:
|
2010-11-10 21:19:25 +00:00
|
|
|
// ugly hack for automatic runway selection on startup based on
|
|
|
|
// metar data. Makes startup.nas obsolete and guarantees the same
|
|
|
|
// runway selection as for AI traffic. However, this code belongs to
|
|
|
|
// somewhere(?) else - if I only new where...
|
|
|
|
if( true == fgGetBool( "/environment/metar/valid" ) ) {
|
2011-09-17 17:26:23 +00:00
|
|
|
SG_LOG(SG_ENVIRONMENT, SG_INFO,
|
|
|
|
"Using METAR for runway selection: '" << fgGetString("/environment/metar/data") << "'" );
|
2010-11-10 21:19:25 +00:00
|
|
|
// the realwx_ctrl fetches metar in the foreground on init,
|
|
|
|
// If it was able to fetch a metar or one was given on the commandline,
|
|
|
|
// the valid flag is set here, otherwise it is false
|
|
|
|
double hdg = fgGetDouble( "/environment/metar/base-wind-dir-deg", 9999.0 );
|
|
|
|
string apt = fgGetString( "/sim/startup/options/airport" );
|
|
|
|
string rwy = fgGetString( "/sim/startup/options/runway" );
|
|
|
|
double strthdg = fgGetDouble( "/sim/startup/options/heading-deg", 9999.0 );
|
2010-11-10 22:28:07 +00:00
|
|
|
string parkpos = fgGetString( "/sim/presets/parkpos" );
|
2010-11-10 21:19:25 +00:00
|
|
|
bool onground = fgGetBool( "/sim/presets/onground", false );
|
|
|
|
// don't check for wind-speed < 1kt, this belongs to the runway-selection code
|
|
|
|
// the other logic is taken from former startup.nas
|
2010-11-10 22:28:07 +00:00
|
|
|
if( hdg < 360.0 && apt.length() > 0 && strthdg > 360.0 && rwy.length() == 0 && onground && parkpos.length() == 0 ) {
|
2010-11-10 21:19:25 +00:00
|
|
|
extern bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg );
|
2012-09-18 19:50:28 +00:00
|
|
|
flightgear::setPosFromAirportIDandHdg( apt, hdg );
|
2010-11-10 21:19:25 +00:00
|
|
|
}
|
2011-09-17 17:26:23 +00:00
|
|
|
} else {
|
|
|
|
SG_LOG(SG_ENVIRONMENT, SG_INFO,
|
|
|
|
"No METAR available to pick active runway" );
|
2010-11-10 21:19:25 +00:00
|
|
|
}
|
2011-05-22 16:28:42 +00:00
|
|
|
|
2012-09-21 17:36:25 +00:00
|
|
|
fgSplashProgress("init-graphics");
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2012-09-18 19:29:36 +00:00
|
|
|
} else if ( idle_state == 900 ) {
|
2005-05-06 09:08:44 +00:00
|
|
|
idle_state = 1000;
|
2010-07-13 20:50:44 +00:00
|
|
|
|
2003-04-15 14:10:47 +00:00
|
|
|
// setup OpenGL view parameters
|
2011-05-22 16:28:42 +00:00
|
|
|
globals->get_renderer()->setupView();
|
1998-07-06 02:42:02 +00:00
|
|
|
|
2004-09-20 13:21:51 +00:00
|
|
|
globals->get_renderer()->resize( fgGetInt("/sim/startup/xsize"),
|
|
|
|
fgGetInt("/sim/startup/ysize") );
|
2012-10-31 00:40:43 +00:00
|
|
|
WindowSystemAdapter::getWSA()->windows[0]->gc->add(
|
|
|
|
new simgear::canvas::VGInitOperation()
|
|
|
|
);
|
2003-09-17 10:02:36 +00:00
|
|
|
|
2009-10-24 09:22:20 +00:00
|
|
|
int session = fgGetInt("/sim/session",0);
|
|
|
|
session++;
|
|
|
|
fgSetInt("/sim/session",session);
|
2005-05-04 21:28:42 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
if ( idle_state == 1000 ) {
|
2003-04-15 14:10:47 +00:00
|
|
|
// We've finished all our initialization steps, from now on we
|
|
|
|
// run the main loop.
|
2005-05-06 09:08:44 +00:00
|
|
|
fgSetBool("sim/sceneryloaded", false);
|
2005-05-04 21:28:42 +00:00
|
|
|
fgRegisterIdleHandler( fgMainLoop );
|
1998-07-06 02:42:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-10 11:46:03 +00:00
|
|
|
static void upper_case_property(const char *name)
|
|
|
|
{
|
2009-07-17 12:54:12 +00:00
|
|
|
using namespace simgear;
|
2006-03-10 11:46:03 +00:00
|
|
|
SGPropertyNode *p = fgGetNode(name, false);
|
|
|
|
if (!p) {
|
|
|
|
p = fgGetNode(name, true);
|
|
|
|
p->setStringValue("");
|
|
|
|
} else {
|
2009-07-17 12:54:12 +00:00
|
|
|
props::Type t = p->getType();
|
|
|
|
if (t == props::NONE || t == props::UNSPECIFIED)
|
2006-03-10 11:46:03 +00:00
|
|
|
p->setStringValue("");
|
|
|
|
else
|
2009-07-17 12:54:12 +00:00
|
|
|
assert(t == props::STRING);
|
2006-03-10 11:46:03 +00:00
|
|
|
}
|
|
|
|
p->addChangeListener(new FGMakeUpperCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-16 20:17:11 +00:00
|
|
|
// Main top level initialization
|
2010-09-29 20:04:11 +00:00
|
|
|
int fgMainInit( int argc, char **argv ) {
|
2001-10-29 04:39:54 +00:00
|
|
|
|
1998-11-16 13:59:58 +00:00
|
|
|
// set default log levels
|
2003-11-24 17:46:38 +00:00
|
|
|
sglog().setLogLevels( SG_ALL, SG_ALERT );
|
1998-11-16 13:59:58 +00:00
|
|
|
|
2001-01-11 05:04:17 +00:00
|
|
|
string version;
|
|
|
|
#ifdef FLIGHTGEAR_VERSION
|
|
|
|
version = FLIGHTGEAR_VERSION;
|
|
|
|
#else
|
|
|
|
version = "unknown version";
|
|
|
|
#endif
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_INFO, "FlightGear: Version "
|
2003-04-15 14:10:47 +00:00
|
|
|
<< version );
|
2012-04-21 18:17:42 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_INFO, "Built with " << SG_COMPILER_STR << std::endl );
|
1998-11-20 01:02:35 +00:00
|
|
|
|
2000-10-19 23:09:33 +00:00
|
|
|
// Allocate global data structures. This needs to happen before
|
|
|
|
// we parse command line options
|
2001-01-12 15:37:40 +00:00
|
|
|
|
2000-10-19 21:24:43 +00:00
|
|
|
globals = new FGGlobals;
|
|
|
|
|
2006-08-07 15:16:46 +00:00
|
|
|
// seed the random number generator
|
2001-01-13 22:06:39 +00:00
|
|
|
sg_srandom_time();
|
|
|
|
|
2001-01-26 00:21:36 +00:00
|
|
|
string_list *col = new string_list;
|
|
|
|
globals->set_channel_options_list( col );
|
|
|
|
|
2008-07-11 16:36:54 +00:00
|
|
|
fgValidatePath("", false); // initialize static variables
|
2006-03-10 11:46:03 +00:00
|
|
|
upper_case_property("/sim/presets/airport-id");
|
|
|
|
upper_case_property("/sim/presets/runway");
|
|
|
|
upper_case_property("/sim/tower/airport-id");
|
2008-06-06 07:49:41 +00:00
|
|
|
upper_case_property("/autopilot/route-manager/input");
|
2006-03-10 11:46:03 +00:00
|
|
|
|
2002-11-16 20:17:11 +00:00
|
|
|
// Load the configuration parameters. (Command line options
|
2006-08-07 15:16:46 +00:00
|
|
|
// override config file options. Config file options override
|
2002-11-16 20:17:11 +00:00
|
|
|
// defaults.)
|
1999-06-18 03:42:54 +00:00
|
|
|
if ( !fgInitConfig(argc, argv) ) {
|
2011-10-16 17:35:40 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_ALERT, "Config option parsing failed ..." );
|
|
|
|
exit(-1);
|
1998-04-24 00:49:17 +00:00
|
|
|
}
|
1999-06-18 03:42:54 +00:00
|
|
|
|
1998-08-20 15:10:33 +00:00
|
|
|
// Initialize the Window/Graphics environment.
|
2004-03-31 21:10:32 +00:00
|
|
|
fgOSInit(&argc, argv);
|
2004-08-24 08:40:41 +00:00
|
|
|
_bootstrap_OSInit++;
|
1998-08-20 15:10:33 +00:00
|
|
|
|
2004-12-20 08:36:56 +00:00
|
|
|
fgRegisterIdleHandler( &fgIdleFunction );
|
2004-03-31 21:10:32 +00:00
|
|
|
|
2010-10-23 19:37:26 +00:00
|
|
|
// Initialize sockets (WinSock needs this)
|
|
|
|
simgear::Socket::initSockets();
|
2005-05-04 21:28:42 +00:00
|
|
|
|
2004-03-31 21:10:32 +00:00
|
|
|
// Clouds3D requires an alpha channel
|
2010-07-01 18:51:05 +00:00
|
|
|
fgOSOpenWindow(true /* request stencil buffer */);
|
2004-03-31 21:10:32 +00:00
|
|
|
|
2005-05-04 21:28:42 +00:00
|
|
|
// Initialize the splash screen right away
|
2005-05-08 14:32:56 +00:00
|
|
|
fntInit();
|
2007-05-03 18:12:29 +00:00
|
|
|
fgSplashInit();
|
2004-05-20 13:27:40 +00:00
|
|
|
|
2004-10-17 17:29:34 +00:00
|
|
|
// pass control off to the master event handler
|
2010-09-29 20:04:11 +00:00
|
|
|
int result = fgOSMainLoop();
|
|
|
|
|
|
|
|
// clean up here; ensure we null globals to avoid
|
|
|
|
// confusing the atexit() handler
|
|
|
|
delete globals;
|
|
|
|
globals = NULL;
|
|
|
|
|
2012-08-27 23:26:36 +00:00
|
|
|
// delete the NavCache here. This will cause the destruction of many cached
|
|
|
|
// objects (eg, airports, navaids, runways).
|
|
|
|
delete flightgear::NavDataCache::instance();
|
|
|
|
|
2010-09-29 20:04:11 +00:00
|
|
|
return result;
|
1998-04-21 17:02:27 +00:00
|
|
|
}
|