1 /**************************************************************************
2 * tilecache.c -- routines to hancle scenery tile caching
4 * Written by Curtis Olson, started January 1998.
6 * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * (Log is kept at end of this file)
24 **************************************************************************/
34 #include <Scenery/bucketutils.h>
35 #include <Scenery/obj.h>
36 #include <Scenery/tilecache.h>
38 #include <Include/general.h>
41 struct fgTILE tile_cache[FG_TILE_CACHE_SIZE];
44 /* Initialize the tile cache subsystem */
45 void fgTileCacheInit( void ) {
48 printf("Initializing the tile cache.\n");
50 for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
51 tile_cache[i].used = 0;
56 /* Return index of next available slot in tile cache */
57 int fgTileCacheNextAvail( void ) {
60 for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
61 if ( tile_cache[i].used == 0 ) {
70 /* Fill in a tile cache entry with real data for the specified bucket */
71 void fgTileCacheEntryFillIn( int index, struct fgBUCKET *p ) {
78 /* Mark this cache entry as used */
79 tile_cache[index].used = 1;
81 /* Update the bucket */
82 tile_cache[index].tile_bucket.lon = p->lon;
83 tile_cache[index].tile_bucket.lat = p->lat;
84 tile_cache[index].tile_bucket.x = p->x;
85 tile_cache[index].tile_bucket.y = p->y;
87 /* Load the appropriate area and get the display list pointer */
88 fgBucketGenBasePath(p, base_path);
89 sprintf(file_name, "%s/Scenery/%s/%ld.obj", g->root_dir,
90 base_path, fgBucketGenIndex(p));
91 tile_cache[index].display_list =
92 fgObjLoad(file_name, &tile_cache[index].local_ref);
96 /* Return info for a tile cache entry */
97 void fgTileCacheEntryInfo( int index, GLint *display_list,
98 struct fgCartesianPoint *local_ref ) {
99 *display_list = tile_cache[index].display_list;
100 /* printf("Display list = %d\n", *display_list); */
102 local_ref->x = tile_cache[index].local_ref.x;
103 local_ref->y = tile_cache[index].local_ref.y;
104 local_ref->z = tile_cache[index].local_ref.z;
108 /* Free the specified cache entry
109 void fgTileCacheEntryFree( in index ) {
115 /* Revision 1.2 1998/01/26 15:55:24 curt
116 /* Progressing on building dynamic scenery system.
118 * Revision 1.1 1998/01/24 00:03:29 curt