]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/main.cxx
Make FGAircraftModel behave like a standarrd subsystem.
[flightgear.git] / src / Main / main.cxx
index 7fbc9d7e4cedd466d47e3c38adddb16721ab1d24..1ed54dfe03a2b3dbd418f3c0a4d1288ba5037d09 100644 (file)
@@ -50,7 +50,6 @@
 #include <simgear/math/sg_random.h>
 
 #include <Time/light.hxx>
-#include <Include/general.hxx>
 #include <Aircraft/replay.hxx>
 #include <Cockpit/cockpit.hxx>
 #include <Cockpit/hud.hxx>
@@ -87,9 +86,6 @@ using namespace flightgear;
 
 using std::cerr;
 
-// This is a record containing a bit of global housekeeping information
-FGGeneral general;
-
 // 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.
@@ -162,20 +158,6 @@ static void fgMainLoop( void ) {
 #endif  
     
     globals->get_subsystem_mgr()->update(sim_dt);
-    globals->get_aircraft_model()->update(sim_dt);
-    
-    //
-    // Tile Manager updates - see if we need to load any new scenery tiles.
-    //   this code ties together the fdm, viewer and scenery classes...
-    //   we may want to move this to its own class at some point
-    //
-    double visibility_meters = fgGetDouble("/environment/visibility-m");
-    globals->get_tile_mgr()->prep_ssg_nodes( visibility_meters );
-
-    // update tile manager for view...
-    SGVec3d viewPos = globals->get_current_view()->get_view_pos();
-    SGGeod geodViewPos = SGGeod::fromCart(viewPos);
-    globals->get_tile_mgr()->update(geodViewPos, visibility_meters);
 
     // run Nasal's settimer() loops right before the view manager
     globals->get_event_mgr()->update(sim_dt);
@@ -238,7 +220,6 @@ static void fgMainLoop( void ) {
               SGRawValueFunctions<const char *>(0, fgSetNewSoundDevice), false);
     }
     simgear::AtomicChangeListener::fireChangeListeners();
-    fgRequestRedraw();
 
     SG_LOG( SG_ALL, SG_DEBUG, "" );
 }
@@ -278,21 +259,23 @@ struct GeneralInitOperation : public GraphicsContextOperation
     }
     void run(osg::GraphicsContext* gc)
     {
-        general.set_glVendor( (char *)glGetString ( GL_VENDOR ) );
-        general.set_glRenderer( (char *)glGetString ( GL_RENDERER ) );
-        general.set_glVersion( (char *)glGetString ( GL_VERSION ) );
-        SG_LOG( SG_GENERAL, SG_INFO, general.get_glVendor() );
-        SG_LOG( SG_GENERAL, SG_INFO, general.get_glRenderer() );
-        SG_LOG( SG_GENERAL, SG_INFO, general.get_glVersion() );
+        SGPropertyNode* simRendering = fgGetNode("/sim/rendering");
+        
+        simRendering->setStringValue("gl-vendor", (char*) glGetString(GL_VENDOR));
+        SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VENDOR));
+        
+        simRendering->setStringValue("gl-renderer", (char*) glGetString(GL_RENDERER));
+        SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_RENDERER));
+        
+        simRendering->setStringValue("gl-version", (char*) glGetString(GL_VERSION));
+        SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VERSION));
 
         GLint tmp;
         glGetIntegerv( GL_MAX_TEXTURE_SIZE, &tmp );
-        general.set_glMaxTexSize( tmp );
-        SG_LOG ( SG_GENERAL, SG_INFO, "Max texture size = " << tmp );
+        simRendering->setIntValue("max-texture-size", tmp);
 
         glGetIntegerv( GL_DEPTH_BITS, &tmp );
-        general.set_glDepthBits( tmp );
-        SG_LOG ( SG_GENERAL, SG_INFO, "Depth buffer bits = " << tmp );
+        simRendering->setIntValue("depth-buffer-bits", tmp);
     }
 };
 
@@ -391,7 +374,6 @@ static void fgIdleFunction ( void ) {
         globals->set_matlib( new SGMaterialLib );
         simgear::SGModelLib::init(globals->get_fg_root());
         simgear::SGModelLib::setPropRoot(globals->get_props());
-        simgear::SGModelLib::setResolveFunc(resolve_path);
         simgear::SGModelLib::setPanelFunc(load_panel);
         
         ////////////////////////////////////////////////////////////////////
@@ -421,9 +403,7 @@ static void fgIdleFunction ( void ) {
         ////////////////////////////////////////////////////////////////////
         FGAircraftModel* acm = new FGAircraftModel;
         globals->set_aircraft_model(acm);
-        //globals->add_subsystem("aircraft-model", acm);
-        acm->init();
-        acm->bind();
+        globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
 
         ////////////////////////////////////////////////////////////////////
         // Initialize the view manager subsystem.
@@ -577,7 +557,7 @@ static void upper_case_property(const char *name)
 
 
 // Main top level initialization
-bool fgMainInit( int argc, char **argv ) {
+int fgMainInit( int argc, char **argv ) {
 
     // set default log levels
     sglog().setLogLevels( SG_ALL, SG_ALERT );
@@ -661,11 +641,14 @@ bool fgMainInit( int argc, char **argv ) {
     fgSplashInit();
 
     // pass control off to the master event handler
-    fgOSMainLoop();
-
-    // we never actually get here ... but to avoid compiler warnings,
-    // etc.
-    return false;
+    int result = fgOSMainLoop();
+    
+    // clean up here; ensure we null globals to avoid
+    // confusing the atexit() handler
+    delete globals;
+    globals = NULL;
+    
+    return result;
 }