]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/newcache.hxx
Check for the plib version when using display lists, just to be sure.
[flightgear.git] / src / Scenery / newcache.hxx
index 7d3c7b3b188438dc889c5d940463d306747aac1d..dfbfcf1900dd1a07a1f3e6560810e69d53775603 100644 (file)
 #  include <config.h>
 #endif
 
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>
-#endif
-
-#include <GL/glut.h>
-
 #include <map>
 
 #include <simgear/bucket/newbucket.hxx>
 
 #include "tileentry.hxx"
 
-FG_USING_STD(map);
-
-
-typedef map < long, FGTileEntry * > tile_map;
-typedef tile_map::iterator tile_map_iterator;
-typedef tile_map::const_iterator const_tile_map_iterator;
-
+SG_USING_STD(map);
 
 // A class to store and manage a pile of tiles
 class FGNewCache {
 
+    typedef map < long, FGTileEntry * > tile_map;
+    typedef tile_map::iterator tile_map_iterator;
+    typedef tile_map::const_iterator const_tile_map_iterator;
+
     // cache storage space
     tile_map tile_cache;
 
@@ -68,32 +60,47 @@ class FGNewCache {
     tile_map_iterator current;
 
     // Free a tile cache entry
-    void FGNewCache::entry_free( long cache_index );
+    void entry_free( long cache_index );
 
 public:
 
     // Constructor
-    FGNewCache( void );
+    FGNewCache();
 
     // Destructor
-    ~FGNewCache( void );
+    ~FGNewCache();
 
     // Initialize the tile cache subsystem 
     void init( void );
 
     // Check if the specified "bucket" exists in the cache
-    bool exists( const FGBucket& b );
+    bool exists( const SGBucket& b ) const;
 
+#if 0
     // Ensure at least one entry is free in the cache
-    void FGNewCache::make_space();
+    bool make_space();
+#endif
+
+    // Return the index of the oldest tile in the cache, return -1 if
+    // nothing available to be removed.
+    long get_oldest_tile();
+
+    // Clear the inner ring flag for all tiles in the cache so that
+    // the external tile scheduler can flag the inner ring correctly.
+    void clear_inner_ring_flags();
+
+    // Clear a cache entry, note that the cache only holds pointers
+    // and this does not free the object which is pointed to.
+    void clear_entry( long cache_entry );
 
-    // Fill in a tile cache entry with real data for the specified bucket 
-    void fill_in( const FGBucket& b );
+    // Clear all completely loaded tiles (ignores partially loaded tiles)
+    void clear_cache();
 
     // Return a pointer to the specified tile cache entry 
     inline FGTileEntry *get_tile( const long tile_index ) {
        tile_map_iterator it = tile_cache.find( tile_index );
        if ( it != tile_cache.end() ) {
+           it->second->set_timestamp(globals->get_sim_time_sec());
            return it->second;
        } else {
            return NULL;
@@ -101,7 +108,7 @@ public:
     }
 
     // Return a pointer to the specified tile cache entry 
-    inline FGTileEntry *get_tile( const FGBucket& b ) {
+    inline FGTileEntry *get_tile( const SGBucket& b ) {
        return get_tile( b.gen_index() );
     }
 
@@ -119,11 +126,14 @@ public:
 
     inline int get_max_cache_size() const { return max_cache_size; }
     inline void set_max_cache_size( int m ) { max_cache_size = m; }
-};
-
 
-// the tile cache
-extern FGNewCache global_tile_cache;
+    /**
+     * Create a new tile and enqueue it for loading.
+     * @param b 
+     * @return success/failure
+     */
+    bool insert_tile( FGTileEntry* e );
+};
 
 
 #endif // _NEWCACHE_HXX