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/bucketutils.h>
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, const 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.13 1998/11/09 23:40:51 curt
108 // Bernie Bright <bbright@c031.aone.net.au> writes:
109 // I've made some changes to the Scenery handling. Basically just tidy ups.
110 // The main difference is in tile.[ch]xx where I've changed list<fgFRAGMENT> to
111 // vector<fgFRAGMENT>. Studying our usage patterns this seems reasonable.
112 // Lists are good if you need to insert/delete elements randomly but we
113 // don't do that. All access seems to be sequential. Two additional
114 // benefits are smaller memory usage - each list element requires pointers
115 // to the next and previous elements, and faster access - vector iterators
116 // are smaller and faster than list iterators. This should also help
117 // Charlie Hotchkiss' problem when compiling with Borland and STLport.
119 // ./Lib/Bucket/bucketutils.hxx
120 // Convenience functions for fgBUCKET.
122 // ./Simulator/Scenery/tile.cxx
123 // ./Simulator/Scenery/tile.hxx
124 // Changed fragment list to a vector.
125 // Added some convenience member functions.
127 // ./Simulator/Scenery/tilecache.cxx
128 // ./Simulator/Scenery/tilecache.hxx
129 // use const fgBUCKET& instead of fgBUCKET* where appropriate.
131 // ./Simulator/Scenery/tilemgr.cxx
132 // ./Simulator/Scenery/tilemgr.hxx
133 // uses all the new convenience functions.
135 // Revision 1.12 1998/10/16 00:55:49 curt
136 // Converted to Point3D class.
138 // Revision 1.11 1998/09/14 12:45:25 curt
141 // Revision 1.10 1998/07/04 00:54:31 curt
142 // Added automatic mipmap generation.
144 // When rendering fragments, use saved model view matrix from associated tile
145 // rather than recalculating it with push() translate() pop().
147 // Revision 1.9 1998/05/23 14:09:22 curt
148 // Added tile.cxx and tile.hxx.
149 // Working on rewriting the tile management system so a tile is just a list
150 // fragments, and the fragment record contains the display list for that fragment.
152 // Revision 1.8 1998/05/20 20:53:54 curt
153 // Moved global ref point and radius (bounding sphere info, and offset) to
154 // data file rather than calculating it on the fly.
155 // Fixed polygon winding problem in scenery generation stage rather than
156 // compensating for it on the fly.
157 // Made a fgTILECACHE class.
159 // Revision 1.7 1998/05/16 13:09:57 curt
160 // Beginning to add support for view frustum culling.
161 // Added some temporary code to calculate bouding radius, until the
162 // scenery generation tools and scenery can be updated.
164 // Revision 1.6 1998/05/07 23:15:20 curt
165 // Fixed a glTexImage2D() usage bug where width and height were mis-swapped.
166 // Added support for --tile-radius=n option.
168 // Revision 1.5 1998/05/02 01:52:17 curt
169 // Playing around with texture coordinates.
171 // Revision 1.4 1998/04/30 12:35:31 curt
172 // Added a command line rendering option specify smooth/flat shading.
174 // Revision 1.3 1998/04/25 22:06:32 curt
175 // Edited cvs log messages in source files ... bad bad bad!
177 // Revision 1.2 1998/04/24 00:51:08 curt
178 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
179 // Tweaked the scenery file extentions to be "file.obj" (uncompressed)
180 // or "file.obz" (compressed.)
182 // Revision 1.1 1998/04/22 13:22:47 curt
183 // C++ - ifing the code a bit.
185 // Revision 1.10 1998/04/21 17:02:45 curt
186 // Prepairing for C++ integration.
188 // Revision 1.9 1998/04/14 02:23:17 curt
189 // Code reorganizations. Added a Lib/ directory for more general libraries.
191 // Revision 1.8 1998/04/08 23:30:08 curt
192 // Adopted Gnu automake/autoconf system.
194 // Revision 1.7 1998/04/03 22:11:38 curt
195 // Converting to Gnu autoconf system.
197 // Revision 1.6 1998/02/18 15:07:10 curt
198 // Tweaks to build with SGI OpenGL (and therefor hopefully other accelerated
199 // drivers will work.)
201 // Revision 1.5 1998/02/16 13:39:45 curt
202 // Miscellaneous weekend tweaks. Fixed? a cache problem that caused whole
203 // tiles to occasionally be missing.
205 // Revision 1.4 1998/01/31 00:43:27 curt
206 // Added MetroWorks patches from Carmen Volpe.
208 // Revision 1.3 1998/01/29 00:51:40 curt
209 // First pass at tile cache, dynamic tile loading and tile unloading now works.
211 // Revision 1.2 1998/01/27 00:48:04 curt
212 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
213 // system and commandline/config file processing code.
215 // Revision 1.1 1998/01/24 00:03:29 curt