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