- // Initialize ssg (from plib). Needs to come before we do any
- // other ssg stuff, but after opengl has been initialized.
- ssgInit();
-
- // Initialize the user interface (we need to do this before
- // passing off control to the OS main loop and before
- // fgInitGeneral to get our fonts !!!
- guiInit();
-
- // Read the list of available aircrafts
- fgReadAircraft();
-
-#ifdef GL_EXT_texture_lod_bias
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, -0.5 ) ;
-#endif
-
- // get the address of our OpenGL extensions
- if ( fgGetBool("/sim/rendering/distance-attenuation") )
- {
- if (SGIsOpenGLExtensionSupported("GL_EXT_point_parameters") ) {
- glPointParameterIsSupported = true;
- glPointParameterfPtr = (glPointParameterfProc)
- SGLookupFunction("glPointParameterfEXT");
- glPointParameterfvPtr = (glPointParameterfvProc)
- SGLookupFunction("glPointParameterfvEXT");
-
- } else if ( SGIsOpenGLExtensionSupported("GL_ARB_point_parameters") ) {
- glPointParameterIsSupported = true;
- glPointParameterfPtr = (glPointParameterfProc)
- SGLookupFunction("glPointParameterfARB");
- glPointParameterfvPtr = (glPointParameterfvProc)
- SGLookupFunction("glPointParameterfvARB");
- } else
- glPointParameterIsSupported = false;
- }
-
- // based on the requested presets, calculate the true starting
- // lon, lat
- fgInitNav();
- fgInitPosition();
-
- SGTime *t = fgInitTime();
- globals->set_time_params( t );
-
- // Do some quick general initializations
- if( !fgInitGeneral()) {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "General initializations failed ..." );
- exit(-1);
- }
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the property-based built-in commands
- ////////////////////////////////////////////////////////////////////
- fgInitCommands();
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the material manager
- ////////////////////////////////////////////////////////////////////
- globals->set_matlib( new SGMaterialLib );
-
- globals->set_model_lib(new SGModelLib);
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the TG scenery subsystem.
- ////////////////////////////////////////////////////////////////////
- globals->set_scenery( new FGScenery );
- globals->get_scenery()->init();
- globals->get_scenery()->bind();
- globals->set_tile_mgr( new FGTileMgr );
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the general model subsystem.
- ////////////////////////////////////////////////////////////////////
- globals->set_model_mgr(new FGModelMgr);
- globals->get_model_mgr()->init();
- globals->get_model_mgr()->bind();
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the 3D aircraft model subsystem (has a dependency on
- // the scenery subsystem.)
- ////////////////////////////////////////////////////////////////////
- globals->set_aircraft_model(new FGAircraftModel);
- globals->get_aircraft_model()->init();
- globals->get_aircraft_model()->bind();
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the view manager subsystem.
- ////////////////////////////////////////////////////////////////////
- FGViewMgr *viewmgr = new FGViewMgr;
- globals->set_viewmgr( viewmgr );
- viewmgr->init();
- viewmgr->bind();
-
-
- // Initialize the sky
- SGPath ephem_data_path( globals->get_fg_root() );
- ephem_data_path.append( "Astro" );
- SGEphemeris *ephem = new SGEphemeris( ephem_data_path.c_str() );
- ephem->update( globals->get_time_params()->getMjd(),
- globals->get_time_params()->getLst(),
- 0.0 );
- globals->set_ephem( ephem );
-
- // TODO: move to environment mgr
- thesky = new SGSky;
- SGPath texture_path(globals->get_fg_root());
- texture_path.append("Textures");
- texture_path.append("Sky");
- for (int i = 0; i < FGEnvironmentMgr::MAX_CLOUD_LAYERS; i++) {
- SGCloudLayer * layer = new SGCloudLayer(texture_path.str());
- thesky->add_cloud_layer(layer);
- }
-
- SGPath sky_tex_path( globals->get_fg_root() );
- sky_tex_path.append( "Textures" );
- sky_tex_path.append( "Sky" );
- thesky->texture_path( sky_tex_path.str() );
-
- // The sun and moon diameters are scaled down numbers of the
- // actual diameters. This was needed to fit bot the sun and the
- // moon within the distance to the far clip plane.
- // Moon diameter: 3,476 kilometers
- // Sun diameter: 1,390,000 kilometers
- thesky->build( 80000.0, 80000.0,
- 463.3, 361.8,
- globals->get_ephem()->getNumPlanets(),
- globals->get_ephem()->getPlanets(),
- globals->get_ephem()->getNumStars(),
- globals->get_ephem()->getStars() );
-
- // Initialize MagVar model
- SGMagVar *magvar = new SGMagVar();
- globals->set_mag( magvar );
-
-
- // kludge to initialize mag compass
- // (should only be done for in-flight
- // startup)
- // update magvar model
- globals->get_mag()->update( fgGetDouble("/position/longitude-deg")
- * SGD_DEGREES_TO_RADIANS,
- fgGetDouble("/position/latitude-deg")
- * SGD_DEGREES_TO_RADIANS,
- fgGetDouble("/position/altitude-ft")
- * SG_FEET_TO_METER,
- globals->get_time_params()->getJD() );
- double var = globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
- fgSetDouble("/instrumentation/heading-indicator/offset-deg", -var);
-
- // airport = new ssgBranch;
- // airport->setName( "Airport Lighting" );
- // lighting->addKid( airport );