1 #ifndef texcache_h_
2 # define texcache_h_
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include "vfs.h"
9 
10 #ifdef USE_OPENGL
11 
12 #define TEXCACHEMAGIC "LZ41"
13 #define GLTEXCACHEADSIZ 8192
14 #define TEXCACHEHASHSIZE 1024
15 
16 enum texcacherr_t
17 {
18     TEXCACHERR_NOERROR,
19     TEXCACHERR_OUTOFMEMORY,  /* unused */
20     TEXCACHERR_BUFFERUNDERRUN,
21     TEXCACHERR_DEDXT,
22     TEXCACHERR_COMPTEX,
23     TEXCACHERR_GETTEXLEVEL,
24     TEXCACHEERRORS
25 };
26 
27 typedef struct texcacheitem_
28 {
29     char    *name;
30     int32_t offset;
31     int32_t len;
32 
33     struct texcacheitem_ *next;
34 } texcacheindex;
35 
36 typedef struct {
37     uint8_t *buf;
38     buildvfs_FILE   index;
39 
40     texcacheindex * first;
41     texcacheindex * current;
42     texcacheindex **entries;
43 
44     pthtyp *list[GLTEXCACHEADSIZ];
45 
46     hashtable_t hashes;
47 
48     int32_t handle;
49     int32_t numentries;
50     int32_t entrybufsiz;
51     int32_t pos;
52 
53     int32_t memsize;
54 } globaltexcache;
55 
56 extern globaltexcache texcache;
57 
58 extern char TEXCACHEFILE[BMAX_PATH];
59 
60 extern int32_t texcache_enabled(void);
61 extern void texcache_freeptrs(void);
62 extern void texcache_syncmemcache(void);
63 extern void texcache_init(void);
64 int texcache_loadoffsets(void);
65 int texcache_readdata(void *outBuf, int32_t len);
66 extern pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth);
67 extern int32_t texcache_loadskin(const texcacheheader *head, int32_t *doalloc, GLuint *glpic, vec2_t *siz);
68 extern int32_t texcache_loadtile(const texcacheheader *head, int32_t *doalloc, pthtyp *pth);
69 extern char const * texcache_calcid(char *outbuf, const char *filename, int32_t len, int32_t dameth, char effect);
70 extern void texcache_prewritetex(texcacheheader *head);
71 void texcache_postwritetex(char const * cacheid, int32_t offset);
72 extern void texcache_writetex_fromdriver(char const * cacheid, texcacheheader *head);
73 extern int texcache_readtexheader(char const * cacheid, texcacheheader *head, int32_t modelp);
74 extern void texcache_openfiles(void);
75 extern void texcache_setupmemcache(void);
76 extern void texcache_checkgarbage(void);
77 extern void texcache_setupindex(void);
78 
79 #endif
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
86