]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - r_textures.h
move CL_RelinkBeams after CL_RelinkNetworkEntities so position is up to date
[xonotic/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
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 mostly private to gl_textures.c
27 typedef struct
28 {
29         // this is exposed (rather than private) for speed reasons only
30         int texnum;
31 }
32 rtexture_t;
33
34 // contents of this structure are private to gl_textures.c
35 typedef struct
36 {
37         int useless;
38 }
39 rtexturepool_t;
40
41 // allocate a texture pool, to be used with R_LoadTexture
42 rtexturepool_t *R_AllocTexturePool(void);
43 // free a texture pool (textures can not be freed individually)
44 void R_FreeTexturePool(rtexturepool_t **rtexturepool);
45
46 // important technical note:
47 // fragment textures must have a width that is compatible with the fragment
48 // update system, to get a compliant size, use R_CompatibleFragmentWidth
49 int R_CompatibleFragmentWidth(int width, int textype, int flags);
50
51 // add a texture to a pool and optionally precache (upload) it
52 // (note: data == NULL is perfectly acceptable)
53 rtexture_t *R_LoadTexture (rtexturepool_t *rtexturepool, char *identifier, int width, int height, qbyte *data, int textype, int flags);
54
55 // free a texture
56 void R_FreeTexture(rtexture_t *rt);
57
58 // update the image data of a texture, used by lightmap updates and
59 // procedural textures.
60 void R_UpdateTexture(rtexture_t *rt, qbyte *data);
61
62 // location of the fragment in the texture (note: any parameter except rt can
63 // be NULL)
64 void R_FragmentLocation(rtexture_t *rt, int *x, int *y, float *fx1, float *fy1, float *fx2, float *fy2);
65
66 // returns the renderer dependent texture slot number (call this before each
67 // use, as a texture might not have been precached)
68 #define R_GetTexture(rt) ((rt) ? ((rt)->texnum >= 0 ? (rt)->texnum : R_RealGetTexture(rt)) : 0)
69 int R_RealGetTexture (rtexture_t *rt);
70
71 // returns true if the texture is transparent (useful for rendering code)
72 int R_TextureHasAlpha(rtexture_t *rt);
73
74 // returns width of texture, as was specified when it was uploaded
75 int R_TextureWidth(rtexture_t *rt);
76
77 // returns height of texture, as was specified when it was uploaded
78 int R_TextureHeight(rtexture_t *rt);
79
80 // frees processing buffers each frame, and may someday animate procedural textures
81 void R_Textures_Frame(void);
82
83 #endif
84