1 #if (USE_POLYMOST == 0) 2 #error Polymost not enabled. 3 #endif 4 #if (USE_OPENGL == 0) 5 #error OpenGL not enabled. 6 #endif 7 8 #ifndef POLYMOSTTEXCACHE_H 9 #define POLYMOSTTEXCACHE_H 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 struct PTCacheTileMip_typ { 16 int sizx, sizy; 17 int length; 18 unsigned char * data; 19 }; 20 typedef struct PTCacheTileMip_typ PTCacheTileMip; 21 22 struct PTCacheTile_typ { 23 char * filename; 24 int effects; 25 int flags; 26 int format; // OpenGL format code 27 int tsizx, tsizy; 28 int nummipmaps; 29 PTCacheTileMip mipmap[1]; 30 }; 31 typedef struct PTCacheTile_typ PTCacheTile; 32 33 /** 34 * Loads the cache index file into memory 35 */ 36 void PTCacheLoadIndex(void); 37 38 /** 39 * Unloads the cache index from memory 40 */ 41 void PTCacheUnloadIndex(void); 42 43 /** 44 * Loads a tile from the cache. 45 * @param filename the filename 46 * @param effects the effects bits 47 * @param flags the flags bits 48 * @return a PTCacheTile entry fully completed 49 */ 50 PTCacheTile * PTCacheLoadTile(const char * filename, int effects, int flags); 51 52 /** 53 * Checks to see if a tile exists in the cache. 54 * @param filename the filename 55 * @param effects the effects bits 56 * @param flags the flags bits 57 * @return !0 if it exists 58 */ 59 int PTCacheHasTile(const char * filename, int effects, int flags); 60 61 /** 62 * Disposes of the resources allocated for a PTCacheTile 63 * @param tdef a PTCacheTile entry 64 */ 65 void PTCacheFreeTile(PTCacheTile * tdef); 66 67 /** 68 * Allocates the skeleton of a PTCacheTile entry for you to complete. 69 * Memory for filenames and mipmap data should be allocated using malloc() 70 * @param nummipmaps allocate mipmap entries for nummipmaps items 71 * @return a PTCacheTile entry 72 */ 73 PTCacheTile * PTCacheAllocNewTile(int nummipmaps); 74 75 /** 76 * Stores a PTCacheTile into the cache. 77 * @param tdef a PTCacheTile entry fully completed 78 * @return !0 on success 79 */ 80 int PTCacheWriteTile(PTCacheTile * tdef); 81 82 /** 83 * Forces the cache to be rebuilt. 84 */ 85 void PTCacheForceRebuild(void); 86 87 #ifdef __cplusplus 88 } 89 #endif 90 91 #endif 92