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 // allocated as a fragment in a larger texture, mipmap is not allowed with
14 // this, mostly used for lightmaps
15 #define TEXF_FRAGMENT 0x00000010
16 // indicates texture coordinates should be clamped rather than wrapping
17 #define TEXF_CLAMP 0x00000020
18 // indicates texture should be uploaded using GL_NEAREST or GL_NEAREST_MIPMAP_NEAREST mode
19 #define TEXF_FORCENEAREST 0x00000040
20 // indicates texture should be uploaded using GL_LINEAR or GL_LINEAR_MIPMAP_NEAREST or GL_LINEAR_MIPMAP_LINEAR mode
21 #define TEXF_FORCELINEAR 0x00000080
22 // indicates texture should be affected by gl_picmip
23 #define TEXF_PICMIP 0x00000100
24 // used for checking if textures mismatch
25 #define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_FRAGMENT | TEXF_CLAMP | TEXF_FORCENEAREST | TEXF_FORCELINEAR | TEXF_PICMIP)
28 #define TEXTYPE_PALETTE 1
32 #define TEXTYPE_RGBA 3
34 #define TEXTYPE_DSDT 4
36 // contents of this structure are mostly private to gl_textures.c
39 // this is exposed (rather than private) for speed reasons only
44 // contents of this structure are private to gl_textures.c
51 // allocate a texture pool, to be used with R_LoadTexture
52 rtexturepool_t *R_AllocTexturePool(void);
53 // free a texture pool (textures can not be freed individually)
54 void R_FreeTexturePool(rtexturepool_t **rtexturepool);
56 // important technical note:
57 // fragment textures must have a width that is compatible with the fragment
58 // update system, to get a compliant size, use R_CompatibleFragmentWidth
59 int R_CompatibleFragmentWidth(int width, int textype, int flags);
61 // add a texture to a pool and optionally precache (upload) it
62 // (note: data == NULL is perfectly acceptable)
63 // (note: palette must not be NULL if using TEXTYPE_PALETTE)
64 rtexture_t *R_LoadTexture1D(rtexturepool_t *rtexturepool, const char *identifier, int width, const qbyte *data, int textype, int flags, const unsigned int *palette);
65 rtexture_t *R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const qbyte *data, int textype, int flags, const unsigned int *palette);
66 rtexture_t *R_LoadTexture3D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, int depth, const qbyte *data, int textype, int flags, const unsigned int *palette);
67 rtexture_t *R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const qbyte *data, int textype, int flags, const unsigned int *palette);
70 void R_FreeTexture(rtexture_t *rt);
72 // update the image data of a texture, used by lightmap updates and
73 // procedural textures.
74 void R_UpdateTexture(rtexture_t *rt, qbyte *data);
76 // location of the fragment in the texture (note: any parameter except rt can
78 void R_FragmentLocation(rtexture_t *rt, int *x, int *y, float *fx1, float *fy1, float *fx2, float *fy2);
79 void R_FragmentLocation3D(rtexture_t *rt, int *x, int *y, int *z, float *fx1, float *fy1, float *fz1, float *fx2, float *fy2, float *fz2);
81 // returns the renderer dependent texture slot number (call this before each
82 // use, as a texture might not have been precached)
83 #define R_GetTexture(rt) ((rt) ? ((rt)->texnum >= 0 ? (rt)->texnum : R_RealGetTexture(rt)) : 0)
84 int R_RealGetTexture (rtexture_t *rt);
86 // returns true if the texture is transparent (useful for rendering code)
87 int R_TextureHasAlpha(rtexture_t *rt);
89 // returns width of texture, as was specified when it was uploaded
90 int R_TextureWidth(rtexture_t *rt);
92 // returns height of texture, as was specified when it was uploaded
93 int R_TextureHeight(rtexture_t *rt);
95 // frees processing buffers each frame, and may someday animate procedural textures
96 void R_Textures_Frame(void);