2014-11-22 12:32:56 +00:00
|
|
|
#ifndef texcache_h_
|
|
|
|
# define texcache_h_
|
2013-05-15 02:17:17 +00:00
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-05-15 02:17:17 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
|
2015-12-23 04:06:05 +00:00
|
|
|
#define TEXCACHEMAGIC "LZ41"
|
2013-05-15 02:17:17 +00:00
|
|
|
#define GLTEXCACHEADSIZ 8192
|
2013-05-17 03:42:37 +00:00
|
|
|
#define TEXCACHEHASHSIZE 1024
|
|
|
|
|
|
|
|
enum texcacherr_t
|
|
|
|
{
|
|
|
|
TEXCACHERR_NOERROR,
|
2014-05-30 00:02:19 +00:00
|
|
|
TEXCACHERR_OUTOFMEMORY, /* unused */
|
2013-05-17 03:42:37 +00:00
|
|
|
TEXCACHERR_BUFFERUNDERRUN,
|
|
|
|
TEXCACHERR_DEDXT,
|
|
|
|
TEXCACHERR_COMPTEX,
|
|
|
|
TEXCACHERR_GETTEXLEVEL,
|
|
|
|
TEXCACHEERRORS
|
|
|
|
};
|
2013-05-15 02:17:17 +00:00
|
|
|
|
2017-06-27 02:24:34 +00:00
|
|
|
typedef struct texcacheitem_
|
2013-05-15 02:17:17 +00:00
|
|
|
{
|
2017-06-27 02:24:34 +00:00
|
|
|
char *name;
|
2013-05-15 02:17:17 +00:00
|
|
|
int32_t offset;
|
|
|
|
int32_t len;
|
|
|
|
|
2017-06-27 02:24:34 +00:00
|
|
|
struct texcacheitem_ *next;
|
|
|
|
} texcacheindex;
|
2013-05-15 02:17:17 +00:00
|
|
|
|
2013-05-17 03:42:37 +00:00
|
|
|
typedef struct {
|
2017-06-27 02:24:34 +00:00
|
|
|
uint8_t *buf;
|
|
|
|
FILE * index;
|
|
|
|
|
|
|
|
texcacheindex * first;
|
|
|
|
texcacheindex * current;
|
|
|
|
texcacheindex **entries;
|
|
|
|
|
2013-05-17 03:42:37 +00:00
|
|
|
pthtyp *list[GLTEXCACHEADSIZ];
|
2017-06-27 02:24:34 +00:00
|
|
|
|
2013-05-17 03:42:37 +00:00
|
|
|
hashtable_t hashes;
|
2017-06-27 02:24:34 +00:00
|
|
|
|
|
|
|
int32_t handle;
|
|
|
|
int32_t numentries;
|
|
|
|
int32_t entrybufsiz;
|
|
|
|
int32_t pos;
|
|
|
|
|
|
|
|
int32_t memsize;
|
2013-05-17 03:42:37 +00:00
|
|
|
} globaltexcache;
|
|
|
|
|
|
|
|
extern globaltexcache texcache;
|
|
|
|
|
2013-05-15 02:17:17 +00:00
|
|
|
extern char TEXCACHEFILE[BMAX_PATH];
|
|
|
|
|
2016-05-04 00:25:06 +00:00
|
|
|
extern int32_t texcache_enabled(void);
|
2013-05-15 02:17:17 +00:00
|
|
|
extern void texcache_freeptrs(void);
|
2013-05-15 02:19:14 +00:00
|
|
|
extern void texcache_syncmemcache(void);
|
2013-05-15 02:17:17 +00:00
|
|
|
extern void texcache_init(void);
|
2017-06-27 02:24:34 +00:00
|
|
|
int texcache_loadoffsets(void);
|
|
|
|
int texcache_readdata(void *outBuf, int32_t len);
|
2013-05-15 02:18:27 +00:00
|
|
|
extern pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth);
|
2016-03-04 19:24:54 +00:00
|
|
|
extern int32_t texcache_loadskin(const texcacheheader *head, int32_t *doalloc, GLuint *glpic, vec2_t *siz);
|
2013-05-15 02:17:17 +00:00
|
|
|
extern int32_t texcache_loadtile(const texcacheheader *head, int32_t *doalloc, pthtyp *pth);
|
2016-05-04 00:25:02 +00:00
|
|
|
extern char const * texcache_calcid(char *cachefn, const char *fn, const int32_t len, const int32_t dameth, const char effect);
|
2016-05-04 00:25:06 +00:00
|
|
|
extern void texcache_prewritetex(texcacheheader *head);
|
2017-06-27 02:24:34 +00:00
|
|
|
void texcache_postwritetex(char const * const cacheid, int32_t const offset);
|
2016-05-04 00:25:06 +00:00
|
|
|
extern void texcache_writetex_fromdriver(char const * cachefn, texcacheheader *head);
|
2017-06-27 02:24:34 +00:00
|
|
|
extern int texcache_readtexheader(char const * cacheid, texcacheheader *head, int32_t modelp);
|
2013-05-15 02:18:27 +00:00
|
|
|
extern void texcache_openfiles(void);
|
|
|
|
extern void texcache_setupmemcache(void);
|
|
|
|
extern void texcache_checkgarbage(void);
|
|
|
|
extern void texcache_setupindex(void);
|
2013-05-15 02:17:17 +00:00
|
|
|
|
|
|
|
#endif
|
2014-11-26 04:39:23 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-30 00:02:19 +00:00
|
|
|
#endif
|