6 #define TEXF_ALPHA 0x00000001
8 #define TEXF_MIPMAP 0x00000002
9 // upload if r_textureprecache >= 1, otherwise defer loading until it is used
10 #define TEXF_PRECACHE 0x00000004
11 // upload immediately, never defer (ignore r_textureprecache)
12 #define TEXF_ALWAYSPRECACHE 0x00000008
13 // indicates texture coordinates should be clamped rather than wrapping
14 #define TEXF_CLAMP 0x00000020
15 // indicates texture should be uploaded using GL_NEAREST or GL_NEAREST_MIPMAP_NEAREST mode
16 #define TEXF_FORCENEAREST 0x00000040
17 // indicates texture should be uploaded using GL_LINEAR or GL_LINEAR_MIPMAP_NEAREST or GL_LINEAR_MIPMAP_LINEAR mode
18 #define TEXF_FORCELINEAR 0x00000080
19 // indicates texture should be affected by gl_picmip and gl_max_size cvar
20 #define TEXF_PICMIP 0x00000100
21 // indicates texture should be compressed if possible
22 #define TEXF_COMPRESS 0x00000200
23 // use this flag to block R_PurgeTexture from freeing a texture
24 #define TEXF_PERSISTENT 0x00000400
25 // indicates texture should use GL_COMPARE_R_TO_TEXTURE mode
26 #define TEXF_COMPARE 0x00000800
27 // indicates texture should use lower precision where supported
28 #define TEXF_LOWPRECISION 0x00001000
29 // indicates texture should support R_UpdateTexture
30 #define TEXF_ALLOWUPDATES 0x00002000
31 // indicates texture should support R_FlushTexture (improving speed on multiple partial updates per draw)
32 #define TEXF_MANUALFLUSHUPDATES 0x00004000
33 // used for checking if textures mismatch
34 #define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_CLAMP | TEXF_FORCENEAREST | TEXF_FORCELINEAR | TEXF_PICMIP | TEXF_COMPRESS | TEXF_COMPARE | TEXF_LOWPRECISION)
36 typedef enum textype_e
42 // 32bit BGRA (preferred format due to faster uploads on most hardware)
44 // 16bit D16 (16bit depth) or 32bit S8D24 (24bit depth, 8bit stencil unused)
49 // contents of this structure are mostly private to gl_textures.c
50 typedef struct rtexture_s
52 // this is exposed (rather than private) for speed reasons only
57 // contents of this structure are private to gl_textures.c
58 typedef struct rtexturepool_s
64 typedef void (*updatecallback_t)(rtexture_t *rt, void *data);
66 // allocate a texture pool, to be used with R_LoadTexture
67 rtexturepool_t *R_AllocTexturePool(void);
68 // free a texture pool (textures can not be freed individually)
69 void R_FreeTexturePool(rtexturepool_t **rtexturepool);
71 // the color/normal/etc cvars should be checked by callers of R_LoadTexture* functions to decide whether to add TEXF_COMPRESS to the flags
72 extern cvar_t gl_texturecompression;
73 extern cvar_t gl_texturecompression_color;
74 extern cvar_t gl_texturecompression_normal;
75 extern cvar_t gl_texturecompression_gloss;
76 extern cvar_t gl_texturecompression_glow;
77 extern cvar_t gl_texturecompression_2d;
78 extern cvar_t gl_texturecompression_q3bsplightmaps;
79 extern cvar_t gl_texturecompression_q3bspdeluxemaps;
80 extern cvar_t gl_texturecompression_sky;
81 extern cvar_t gl_texturecompression_lightcubemaps;
83 // add a texture to a pool and optionally precache (upload) it
84 // (note: data == NULL is perfectly acceptable)
85 // (note: palette must not be NULL if using TEXTYPE_PALETTE)
86 rtexture_t *R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, textype_t textype, int flags, const unsigned int *palette);
87 rtexture_t *R_LoadTexture3D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int depth, const unsigned char *data, textype_t textype, int flags, const unsigned int *palette);
88 rtexture_t *R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, textype_t textype, int flags, const unsigned int *palette);
89 rtexture_t *R_LoadTextureRectangle(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, textype_t textype, int flags, const unsigned int *palette);
90 rtexture_t *R_LoadTextureShadowMapRectangle(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int precision, qboolean filter);
91 rtexture_t *R_LoadTextureShadowMap2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int precision, qboolean filter);
92 rtexture_t *R_LoadTextureShadowMapCube(rtexturepool_t *rtexturepool, const char *identifier, int width, int precision, qboolean filter);
95 void R_FreeTexture(rtexture_t *rt);
97 // update a portion of the image data of a texture, used by lightmap updates
98 // and procedural textures such as video playback.
99 // if TEXF_MANUALFLUSHUPDATES is used, you MUST call R_FlushTexture to apply the updates
100 void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int width, int height);
101 // if TEXF_MANUALFLUSHUPDATES is used, call this to apply the updates,
102 // otherwise this function does nothing
103 void R_FlushTexture(rtexture_t *rt);
105 // returns the renderer dependent texture slot number (call this before each
106 // use, as a texture might not have been precached)
107 #define R_GetTexture(rt) ((rt) ? ((rt)->texnum > 0 ? (rt)->texnum : R_RealGetTexture(rt)) : r_texture_white->texnum)
108 int R_RealGetTexture (rtexture_t *rt);
110 // returns width of texture, as was specified when it was uploaded
111 int R_TextureWidth(rtexture_t *rt);
113 // returns height of texture, as was specified when it was uploaded
114 int R_TextureHeight(rtexture_t *rt);
116 // only frees the texture if TEXF_PERSISTENT is not set
117 // also resets the variable
118 void R_PurgeTexture(rtexture_t *prt);
120 // frees processing buffers each frame, and may someday animate procedural textures
121 void R_Textures_Frame(void);
123 // maybe rename this - sounds awful? [11/21/2007 Black]
124 void R_MarkDirtyTexture(rtexture_t *rt);
125 void R_MakeTextureDynamic(rtexture_t *rt, updatecallback_t updatecallback, void *data);
127 // Clear the texture's contents
128 void R_ClearTexture (rtexture_t *rt);