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 // used for checking if textures mismatch
24 #define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_CLAMP | TEXF_FORCENEAREST | TEXF_FORCELINEAR | TEXF_PICMIP | TEXF_COMPRESS)
27 #define TEXTYPE_PALETTE 1
31 #define TEXTYPE_RGBA 3
33 // contents of this structure are mostly private to gl_textures.c
34 typedef struct rtexture_s
36 // this is exposed (rather than private) for speed reasons only
41 // contents of this structure are private to gl_textures.c
42 typedef struct rtexturepool_s
48 // allocate a texture pool, to be used with R_LoadTexture
49 rtexturepool_t *R_AllocTexturePool(void);
50 // free a texture pool (textures can not be freed individually)
51 void R_FreeTexturePool(rtexturepool_t **rtexturepool);
53 // the color/normal/etc cvars should be checked by callers of R_LoadTexture* functions to decide whether to add TEXF_COMPRESS to the flags
54 extern cvar_t gl_texturecompression;
55 extern cvar_t gl_texturecompression_color;
56 extern cvar_t gl_texturecompression_normal;
57 extern cvar_t gl_texturecompression_gloss;
58 extern cvar_t gl_texturecompression_glow;
59 extern cvar_t gl_texturecompression_2d;
60 extern cvar_t gl_texturecompression_q3bsplightmaps;
61 extern cvar_t gl_texturecompression_q3bspdeluxemaps;
62 extern cvar_t gl_texturecompression_sky;
63 extern cvar_t gl_texturecompression_lightcubemaps;
65 // add a texture to a pool and optionally precache (upload) it
66 // (note: data == NULL is perfectly acceptable)
67 // (note: palette must not be NULL if using TEXTYPE_PALETTE)
68 rtexture_t *R_LoadTexture1D(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, int textype, int flags, const unsigned int *palette);
69 rtexture_t *R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, int textype, int flags, const unsigned int *palette);
70 rtexture_t *R_LoadTexture3D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int depth, const unsigned char *data, int textype, int flags, const unsigned int *palette);
71 rtexture_t *R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, int textype, int flags, const unsigned int *palette);
74 void R_FreeTexture(rtexture_t *rt);
76 // update a portion of the image data of a texture, used by lightmap updates
77 // and procedural textures such as video playback.
78 void R_UpdateTexture(rtexture_t *rt, unsigned char *data, int x, int y, int width, int height);
80 // returns the renderer dependent texture slot number (call this before each
81 // use, as a texture might not have been precached)
82 #define R_GetTexture(rt) ((rt) ? ((rt)->texnum >= 0 ? (rt)->texnum : R_RealGetTexture(rt)) : r_texture_white->texnum)
83 int R_RealGetTexture (rtexture_t *rt);
85 // returns true if the texture is transparent (useful for rendering code)
86 int R_TextureHasAlpha(rtexture_t *rt);
88 // returns width of texture, as was specified when it was uploaded
89 int R_TextureWidth(rtexture_t *rt);
91 // returns height of texture, as was specified when it was uploaded
92 int R_TextureHeight(rtexture_t *rt);
94 // frees processing buffers each frame, and may someday animate procedural textures
95 void R_Textures_Frame(void);