]> icculus.org git repositories - divverent/darkplaces.git/blob - r_textures.h
corrected comment again, indicating that the offset for polygon 3 is in the bottom...
[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
15 #define TEXF_FRAGMENT 0x00000010
16 // indicates texture coordinates should be clamped rather than wrapping
17 #define TEXF_CLAMP 0x00000020
18 // used for checking if textures mismatch
19 #define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_FRAGMENT | TEXF_CLAMP)
20
21 // 8bit paletted
22 #define TEXTYPE_PALETTE 1
23 // 24bit RGB
24 #define TEXTYPE_RGB 2
25 // 32bit RGBA
26 #define TEXTYPE_RGBA 3
27
28 // contents of this structure are mostly private to gl_textures.c
29 typedef struct
30 {
31         // this is exposed (rather than private) for speed reasons only
32         int texnum;
33 }
34 rtexture_t;
35
36 // contents of this structure are private to gl_textures.c
37 typedef struct
38 {
39         int useless;
40 }
41 rtexturepool_t;
42
43 // allocate a texture pool, to be used with R_LoadTexture
44 rtexturepool_t *R_AllocTexturePool(void);
45 // free a texture pool (textures can not be freed individually)
46 void R_FreeTexturePool(rtexturepool_t **rtexturepool);
47
48 // important technical note:
49 // fragment textures must have a width that is compatible with the fragment
50 // update system, to get a compliant size, use R_CompatibleFragmentWidth
51 int R_CompatibleFragmentWidth(int width, int textype, int flags);
52
53 // add a texture to a pool and optionally precache (upload) it
54 // (note: data == NULL is perfectly acceptable)
55 // (note: palette must not be NULL if using TEXTYPE_PALETTE)
56 rtexture_t *R_LoadTexture1D(rtexturepool_t *rtexturepool, const char *identifier, int width, const qbyte *data, int textype, int flags, const unsigned int *palette);
57 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);
58 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);
59 rtexture_t *R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const qbyte *data, int textype, int flags, const unsigned int *palette);
60
61 // free a texture
62 void R_FreeTexture(rtexture_t *rt);
63
64 // update the image data of a texture, used by lightmap updates and
65 // procedural textures.
66 void R_UpdateTexture(rtexture_t *rt, qbyte *data);
67
68 // location of the fragment in the texture (note: any parameter except rt can
69 // be NULL)
70 void R_FragmentLocation(rtexture_t *rt, int *x, int *y, float *fx1, float *fy1, float *fx2, float *fy2);
71 void R_FragmentLocation3D(rtexture_t *rt, int *x, int *y, int *z, float *fx1, float *fy1, float *fz1, float *fx2, float *fy2, float *fz2);
72
73 // returns the renderer dependent texture slot number (call this before each
74 // use, as a texture might not have been precached)
75 #define R_GetTexture(rt) ((rt) ? ((rt)->texnum >= 0 ? (rt)->texnum : R_RealGetTexture(rt)) : 0)
76 int R_RealGetTexture (rtexture_t *rt);
77
78 // returns true if the texture is transparent (useful for rendering code)
79 int R_TextureHasAlpha(rtexture_t *rt);
80
81 // returns width of texture, as was specified when it was uploaded
82 int R_TextureWidth(rtexture_t *rt);
83
84 // returns height of texture, as was specified when it was uploaded
85 int R_TextureHeight(rtexture_t *rt);
86
87 // frees processing buffers each frame, and may someday animate procedural textures
88 void R_Textures_Frame(void);
89
90 #endif
91