]> git.mxchange.org Git - flightgear.git/blob - Scenery/tilecache.hxx
MSVC++ portability tweaks contributed by Bernie Bright.
[flightgear.git] / Scenery / tilecache.hxx
1 // tilecache.hxx -- routines to handle scenery tile caching
2 //
3 // Written by Curtis Olson, started January 1998.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifndef _TILECACHE_HXX
26 #define _TILECACHE_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33
34 #ifdef HAVE_CONFIG_H
35 #  include <config.h>
36 #endif
37
38 #ifdef HAVE_WINDOWS_H
39 #  include <windows.h>
40 #endif
41
42 #include <GL/glut.h>
43 #include <XGL/xgl.h>
44
45 #include <Bucket/bucketutils.h>
46 #include <Math/point3d.hxx>
47
48 #include "tile.hxx"
49
50
51 // For best results ... i.e. to avoid tile load problems and blank areas
52 //
53 // FG_TILE_CACHE_SIZE >= (o->tile_diameter + 1) ** 2 
54 #define FG_TILE_CACHE_SIZE 121
55
56 // A class to store and manage a pile of tiles
57 class fgTILECACHE {
58
59 //     enum
60 //     {
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
64 //     };
65
66     // cache storage space
67     fgTILE tile_cache[ FG_TILE_CACHE_SIZE ];
68
69 public:
70
71     // Constructor
72     fgTILECACHE( void );
73
74     // Initialize the tile cache subsystem 
75     void init( void );
76
77     // Search for the specified "bucket" in the cache 
78     int exists( const fgBUCKET& p );
79
80     // Return index of next available slot in tile cache 
81     int next_avail( void );
82
83     // Free a tile cache entry
84     void entry_free( int index );
85
86     // Fill in a tile cache entry with real data for the specified bucket 
87     void fill_in( int index, const fgBUCKET& p );
88
89     // Return a pointer to the specified tile cache entry 
90     fgTILE *get_tile( int index ) {
91         return &tile_cache[index];
92     }
93
94     // Destructor
95     ~fgTILECACHE( void );
96 };
97
98
99 // the tile cache
100 extern fgTILECACHE global_tile_cache;
101
102
103 #endif // _TILECACHE_HXX 
104
105
106 // $Log$
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.
118 //
119 // ./Lib/Bucket/bucketutils.hxx
120 //   Convenience functions for fgBUCKET.
121 //
122 // ./Simulator/Scenery/tile.cxx
123 // ./Simulator/Scenery/tile.hxx
124 //   Changed fragment list to a vector.
125 //   Added some convenience member functions.
126 //
127 // ./Simulator/Scenery/tilecache.cxx
128 // ./Simulator/Scenery/tilecache.hxx
129 //   use const fgBUCKET& instead of fgBUCKET* where appropriate.
130 //
131 // ./Simulator/Scenery/tilemgr.cxx
132 // ./Simulator/Scenery/tilemgr.hxx
133 //   uses all the new convenience functions.
134 //
135 // Revision 1.12  1998/10/16 00:55:49  curt
136 // Converted to Point3D class.
137 //
138 // Revision 1.11  1998/09/14 12:45:25  curt
139 // minor tweaks.
140 //
141 // Revision 1.10  1998/07/04 00:54:31  curt
142 // Added automatic mipmap generation.
143 //
144 // When rendering fragments, use saved model view matrix from associated tile
145 // rather than recalculating it with push() translate() pop().
146 //
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.
151 //
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.
158 //
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.
163 //
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.
167 //
168 // Revision 1.5  1998/05/02 01:52:17  curt
169 // Playing around with texture coordinates.
170 //
171 // Revision 1.4  1998/04/30 12:35:31  curt
172 // Added a command line rendering option specify smooth/flat shading.
173 //
174 // Revision 1.3  1998/04/25 22:06:32  curt
175 // Edited cvs log messages in source files ... bad bad bad!
176 //
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.)
181 //
182 // Revision 1.1  1998/04/22 13:22:47  curt
183 // C++ - ifing the code a bit.
184 //
185 // Revision 1.10  1998/04/21 17:02:45  curt
186 // Prepairing for C++ integration.
187 //
188 // Revision 1.9  1998/04/14 02:23:17  curt
189 // Code reorganizations.  Added a Lib/ directory for more general libraries.
190 //
191 // Revision 1.8  1998/04/08 23:30:08  curt
192 // Adopted Gnu automake/autoconf system.
193 //
194 // Revision 1.7  1998/04/03 22:11:38  curt
195 // Converting to Gnu autoconf system.
196 //
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.)
200 //
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.
204 //
205 // Revision 1.4  1998/01/31 00:43:27  curt
206 // Added MetroWorks patches from Carmen Volpe.
207 //
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.
210 //
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.
214 //
215 // Revision 1.1  1998/01/24 00:03:29  curt
216 // Initial revision.
217
218