]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/FGTileLoader.cxx
Check for the plib version when using display lists, just to be sure.
[flightgear.git] / src / Scenery / FGTileLoader.cxx
index 661833e2824e7ee17477908d57a56a68801113a0..255e76b85bb117ee7314999ebb235b406fa35476 100644 (file)
@@ -24,6 +24,8 @@
 #  include <config.h>
 #endif
 
+#include <simgear/compiler.h>
+
 #include <Main/globals.hxx>
 #include "FGTileLoader.hxx"
 #include "tileentry.hxx"
 extern ssgBranch *terrain;
 extern ssgBranch *ground;
 
+
 /**
  * 
  */
 FGTileLoader::FGTileLoader()
 {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     // Create and start the loader threads.
     for (int i = 0; i < MAX_THREADS; ++i)
     {
@@ -52,7 +55,7 @@ FGTileLoader::FGTileLoader()
  */
 FGTileLoader::~FGTileLoader()
 {
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     // Wake up its time to die.
     // queue_cond.broadcast();
 
@@ -64,6 +67,19 @@ FGTileLoader::~FGTileLoader()
 #endif // ENABLE_THREADS
 }
 
+
+#if 0 // we don't ever want to do this I don't think
+/**
+ * 
+ */
+void FGTileLoader::reinit() {
+    while ( !tile_load_queue.empty() ) {
+       tile_load_queue.pop();
+    }
+}
+#endif
+
+
 /**
  * 
  */
@@ -72,18 +88,12 @@ FGTileLoader::add( FGTileEntry* tile )
 {
     /**
      * Initialise tile_path here and not in ctor to avoid problems
-     * with the initialastion order of global objects.
+     * with the initialisation order of global objects.
      */
     static bool beenhere = false;
-    if (!beenhere)
-    {
-       if ( globals->get_fg_scenery() != (string)"" ) {
-           tile_path.set( globals->get_fg_scenery() );
-       } else {
-           tile_path.set( globals->get_fg_root() );
-           tile_path.append( "Scenery" );
-       }
-       beenhere = true;
+    if (!beenhere) {
+        tile_path = globals->get_fg_scenery();
+        beenhere = true;
     }
 
     tile_load_queue.push( tile );
@@ -106,7 +116,8 @@ FGTileLoader::remove( FGTileEntry* tile )
 void
 FGTileLoader::update()
 {
-#ifdef ENABLE_THREADS
+
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
     // send a signal to the pager thread that it is allowed to load
     // another tile
     mutex.lock();
@@ -114,28 +125,33 @@ FGTileLoader::update()
     mutex.unlock();
 #else
     if ( !tile_load_queue.empty() ) {
-        cout << "loading next tile ..." << endl;
+        // cout << "loading next tile ..." << endl;
         // load the next tile in the queue
         FGTileEntry* tile = tile_load_queue.front();
         tile_load_queue.pop();
+
         tile->load( tile_path, true );
-        FGTileMgr::loaded( tile );
+
+        FGTileMgr::ready_to_attach( tile );
     }
 
+#ifdef WISH_PLIB_WAS_THREADED // but it isn't
     if ( !tile_free_queue.empty() ) {
-        cout << "freeing next tile ..." << endl;
+        // cout << "freeing next tile ..." << endl;
         // free the next tile in the queue
         FGTileEntry* tile = tile_free_queue.front();
         tile_free_queue.pop();
        tile->free_tile();
        delete tile;
     }
+#endif
 
 #endif // ENABLE_THREADS
+
 }
 
 
-#ifdef ENABLE_THREADS
+#if defined(ENABLE_THREADS) && ENABLE_THREADS
 /**
  * 
  */
@@ -161,7 +177,7 @@ FGTileLoader::LoaderThread::run()
 #ifdef WISH_PLIB_WAS_THREADED // but it isn't
        // Handle and pending removals
        while ( !loader->tile_free_queue.empty() ) {
-           cout << "freeing next tile ..." << endl;
+           // cout << "freeing next tile ..." << endl;
            // free the next tile in the queue
            FGTileEntry* tile = loader->tile_free_queue.pop();
            tile->free_tile();