]> icculus.org git repositories - divverent/darkplaces.git/blob - r_textures.h
3abbe5839a951e47cb7b6de7cd00056ae394a011
[divverent/darkplaces.git] / r_textures.h
1
2 #ifndef R_TEXTURES_H
3 #define R_TEXTURES_H
4
5 // transparent
6 #define TEXF_ALPHA 0x00000001
7 // mipmapped
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 (which are procedural textures)
15 #define TEXF_FRAGMENT 0x00000010
16 // used for checking if textures mismatch
17 #define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_FRAGMENT)
18
19 // 8bit quake paletted
20 #define TEXTYPE_QPALETTE 1
21 // 24bit RGB
22 #define TEXTYPE_RGB 2
23 // 32bit RGBA
24 #define TEXTYPE_RGBA 3
25
26 // contents of this structure are private to gl_textures.c
27 typedef struct
28 {
29         int useless;
30 }
31 rtexture_t;
32
33 // contents of this structure are private to gl_textures.c
34 typedef struct
35 {
36         int useless;
37 }
38 rtexturepool_t;
39
40 // allocate a texture pool, to be used with R_LoadTexture/R_ProceduralTexture
41 rtexturepool_t *R_AllocTexturePool(void);
42 // free a texture pool (textures can not be freed individually)
43 void R_FreeTexturePool(rtexturepool_t **rtexturepool);
44
45 // important technical note:
46 // fragment textures must have a width that is compatible with the fragment
47 // update system, to get a compliant size, use R_CompatibleFragmentWidth
48 int R_CompatibleFragmentWidth(int width, int textype, int flags);
49
50 // these two functions add a texture to a pool, and may precache (upload) it
51 // a normal static texture
52 rtexture_t *R_LoadTexture (rtexturepool_t *rtexturepool, char *identifier, int width, int height, qbyte *data, int textype, int flags);
53 // a procedurally generated texture, often animated over time, note: generate can be NULL (for odd uses)
54 rtexture_t *R_ProceduralTexture (rtexturepool_t *rtexturepool, char *identifier, int width, int height, int textype, int flags, int (*generate)(qbyte *buffer, int width, int height, void *parameterdata, int parameterdatasize), void *parameterdata, int parameterdatasize);
55
56 // update the image data of a texture, used by lightmap updates and procedural
57 // textures.
58 void R_UpdateTexture(rtexture_t *rt, qbyte *data);
59
60 // location of the fragment in the texture (note: any parameter except rt can be NULL)
61 void R_FragmentLocation(rtexture_t *rt, int *x, int *y, float *fx1, float *fy1, float *fx2, float *fy2);
62
63 // returns the renderer dependent texture slot number (call this before each use, as a texture might not have been precached, or it might change over time if it is procedural)
64 int R_GetTexture (rtexture_t *rt);
65
66 // returns true if the texture is transparent (useful for rendering code)
67 int R_TextureHasAlpha(rtexture_t *rt);
68
69 // returns width of texture, as was specified when it was uploaded
70 int R_TextureWidth(rtexture_t *rt);
71
72 // returns height of texture, as was specified when it was uploaded
73 int R_TextureHeight(rtexture_t *rt);
74
75 #endif
76