]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - r_textures.h
improved server handling of multiple packets per client physics frame (as would be...
[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 // 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 and gl_max_size cvar
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)
26
27 // 8bit paletted
28 #define TEXTYPE_PALETTE 1
29 // 24bit RGB
30 #define TEXTYPE_RGB 2
31 // 32bit RGBA
32 #define TEXTYPE_RGBA 3
33 // 16bit DSDT
34 #define TEXTYPE_DSDT 4
35
36 // contents of this structure are mostly private to gl_textures.c
37 typedef struct rtexture_s
38 {
39         // this is exposed (rather than private) for speed reasons only
40         int texnum;
41 }
42 rtexture_t;
43
44 // contents of this structure are private to gl_textures.c
45 typedef struct rtexturepool_s
46 {
47         int useless;
48 }
49 rtexturepool_t;
50
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);
55
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);
60
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 unsigned char *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 unsigned char *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 unsigned char *data, int textype, int flags, const unsigned int *palette);
67 rtexture_t *R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, int textype, int flags, const unsigned int *palette);
68
69 // free a texture
70 void R_FreeTexture(rtexture_t *rt);
71
72 // update the image data of a texture, used by lightmap updates and
73 // procedural textures.
74 void R_UpdateTexture(rtexture_t *rt, unsigned char *data);
75
76 // location of the fragment in the texture (note: any parameter except rt can
77 // be NULL)
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);
80
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);
85
86 // returns true if the texture is transparent (useful for rendering code)
87 int R_TextureHasAlpha(rtexture_t *rt);
88
89 // returns width of texture, as was specified when it was uploaded
90 int R_TextureWidth(rtexture_t *rt);
91
92 // returns height of texture, as was specified when it was uploaded
93 int R_TextureHeight(rtexture_t *rt);
94
95 // frees processing buffers each frame, and may someday animate procedural textures
96 void R_Textures_Frame(void);
97
98 #endif
99