1 // tilecache.hxx -- routines to handle scenery tile caching
3 // Written by Curtis Olson, started January 1998.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 // (Log is kept at end of this file)
25 #ifndef _TILECACHE_HXX
26 #define _TILECACHE_HXX
30 # error This library requires C++
45 #include <Bucket/newbucket.hxx>
46 #include <Math/point3d.hxx>
51 // For best results ... i.e. to avoid tile load problems and blank areas
53 // FG_TILE_CACHE_SIZE >= (o->tile_diameter + 1) ** 2
54 #define FG_TILE_CACHE_SIZE 121
56 // A class to store and manage a pile of tiles
61 // // For best results... i.e. to avoid tile load problems and blank areas
62 // // FG_TILE_CACHE_SIZE >= (o->tile_diameter + 1) ** 2
63 // FG_TILE_CACHE_SIZE = 121
66 // cache storage space
67 fgTILE tile_cache[ FG_TILE_CACHE_SIZE ];
74 // Initialize the tile cache subsystem
77 // Search for the specified "bucket" in the cache
78 int exists( const FGBucket& p );
80 // Return index of next available slot in tile cache
81 int next_avail( void );
83 // Free a tile cache entry
84 void entry_free( int index );
86 // Fill in a tile cache entry with real data for the specified bucket
87 void fill_in( int index, FGBucket& p );
89 // Return a pointer to the specified tile cache entry
90 fgTILE *get_tile( int index ) {
91 return &tile_cache[index];
100 extern fgTILECACHE global_tile_cache;
103 #endif // _TILECACHE_HXX
107 // Revision 1.1 1999/04/05 21:32:49 curt
110 // Revision 1.14 1999/03/25 19:03:27 curt
111 // Converted to use new bucket routines.
113 // Revision 1.13 1998/11/09 23:40:51 curt
114 // Bernie Bright <bbright@c031.aone.net.au> writes:
115 // I've made some changes to the Scenery handling. Basically just tidy ups.
116 // The main difference is in tile.[ch]xx where I've changed list<fgFRAGMENT> to
117 // vector<fgFRAGMENT>. Studying our usage patterns this seems reasonable.
118 // Lists are good if you need to insert/delete elements randomly but we
119 // don't do that. All access seems to be sequential. Two additional
120 // benefits are smaller memory usage - each list element requires pointers
121 // to the next and previous elements, and faster access - vector iterators
122 // are smaller and faster than list iterators. This should also help
123 // Charlie Hotchkiss' problem when compiling with Borland and STLport.
125 // ./Lib/Bucket/bucketutils.hxx
126 // Convenience functions for fgBUCKET.
128 // ./Simulator/Scenery/tile.cxx
129 // ./Simulator/Scenery/tile.hxx
130 // Changed fragment list to a vector.
131 // Added some convenience member functions.
133 // ./Simulator/Scenery/tilecache.cxx
134 // ./Simulator/Scenery/tilecache.hxx
135 // use const fgBUCKET& instead of fgBUCKET* where appropriate.
137 // ./Simulator/Scenery/tilemgr.cxx
138 // ./Simulator/Scenery/tilemgr.hxx
139 // uses all the new convenience functions.
141 // Revision 1.12 1998/10/16 00:55:49 curt
142 // Converted to Point3D class.
144 // Revision 1.11 1998/09/14 12:45:25 curt
147 // Revision 1.10 1998/07/04 00:54:31 curt
148 // Added automatic mipmap generation.
150 // When rendering fragments, use saved model view matrix from associated tile
151 // rather than recalculating it with push() translate() pop().
153 // Revision 1.9 1998/05/23 14:09:22 curt
154 // Added tile.cxx and tile.hxx.
155 // Working on rewriting the tile management system so a tile is just a list
156 // fragments, and the fragment record contains the display list for that fragment.
158 // Revision 1.8 1998/05/20 20:53:54 curt
159 // Moved global ref point and radius (bounding sphere info, and offset) to
160 // data file rather than calculating it on the fly.
161 // Fixed polygon winding problem in scenery generation stage rather than
162 // compensating for it on the fly.
163 // Made a fgTILECACHE class.
165 // Revision 1.7 1998/05/16 13:09:57 curt
166 // Beginning to add support for view frustum culling.
167 // Added some temporary code to calculate bouding radius, until the
168 // scenery generation tools and scenery can be updated.
170 // Revision 1.6 1998/05/07 23:15:20 curt
171 // Fixed a glTexImage2D() usage bug where width and height were mis-swapped.
172 // Added support for --tile-radius=n option.
174 // Revision 1.5 1998/05/02 01:52:17 curt
175 // Playing around with texture coordinates.
177 // Revision 1.4 1998/04/30 12:35:31 curt
178 // Added a command line rendering option specify smooth/flat shading.
180 // Revision 1.3 1998/04/25 22:06:32 curt
181 // Edited cvs log messages in source files ... bad bad bad!
183 // Revision 1.2 1998/04/24 00:51:08 curt
184 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
185 // Tweaked the scenery file extentions to be "file.obj" (uncompressed)
186 // or "file.obz" (compressed.)
188 // Revision 1.1 1998/04/22 13:22:47 curt
189 // C++ - ifing the code a bit.
191 // Revision 1.10 1998/04/21 17:02:45 curt
192 // Prepairing for C++ integration.
194 // Revision 1.9 1998/04/14 02:23:17 curt
195 // Code reorganizations. Added a Lib/ directory for more general libraries.
197 // Revision 1.8 1998/04/08 23:30:08 curt
198 // Adopted Gnu automake/autoconf system.
200 // Revision 1.7 1998/04/03 22:11:38 curt
201 // Converting to Gnu autoconf system.
203 // Revision 1.6 1998/02/18 15:07:10 curt
204 // Tweaks to build with SGI OpenGL (and therefor hopefully other accelerated
205 // drivers will work.)
207 // Revision 1.5 1998/02/16 13:39:45 curt
208 // Miscellaneous weekend tweaks. Fixed? a cache problem that caused whole
209 // tiles to occasionally be missing.
211 // Revision 1.4 1998/01/31 00:43:27 curt
212 // Added MetroWorks patches from Carmen Volpe.
214 // Revision 1.3 1998/01/29 00:51:40 curt
215 // First pass at tile cache, dynamic tile loading and tile unloading now works.
217 // Revision 1.2 1998/01/27 00:48:04 curt
218 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
219 // system and commandline/config file processing code.
221 // Revision 1.1 1998/01/24 00:03:29 curt