]> icculus.org git repositories - divverent/darkplaces.git/blob - r_textures.h
and now I see that the added frags counter requires shifting the flag status icons...
[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 // indicates texture coordinates should be clamped rather than wrapping
14 #define TEXF_CLAMP 0x00000020
15 // indicates texture should be uploaded using GL_NEAREST or GL_NEAREST_MIPMAP_NEAREST mode
16 #define TEXF_FORCENEAREST 0x00000040
17 // indicates texture should be uploaded using GL_LINEAR or GL_LINEAR_MIPMAP_NEAREST or GL_LINEAR_MIPMAP_LINEAR mode
18 #define TEXF_FORCELINEAR 0x00000080
19 // indicates texture should be affected by gl_picmip and gl_max_size cvar
20 #define TEXF_PICMIP 0x00000100
21 // used for checking if textures mismatch
22 #define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_CLAMP | TEXF_FORCENEAREST | TEXF_FORCELINEAR | TEXF_PICMIP)
23
24 // 8bit paletted
25 #define TEXTYPE_PALETTE 1
26 // 24bit RGB
27 #define TEXTYPE_RGB 2
28 // 32bit RGBA
29 #define TEXTYPE_RGBA 3
30
31 // contents of this structure are mostly private to gl_textures.c
32 typedef struct rtexture_s
33 {
34         // this is exposed (rather than private) for speed reasons only
35         int texnum;
36 }
37 rtexture_t;
38
39 // contents of this structure are private to gl_textures.c
40 typedef struct rtexturepool_s
41 {
42         int useless;
43 }
44 rtexturepool_t;
45
46 // allocate a texture pool, to be used with R_LoadTexture
47 rtexturepool_t *R_AllocTexturePool(void);
48 // free a texture pool (textures can not be freed individually)
49 void R_FreeTexturePool(rtexturepool_t **rtexturepool);
50
51 // add a texture to a pool and optionally precache (upload) it
52 // (note: data == NULL is perfectly acceptable)
53 // (note: palette must not be NULL if using TEXTYPE_PALETTE)
54 rtexture_t *R_LoadTexture1D(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, int textype, int flags, const unsigned int *palette);
55 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);
56 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);
57 rtexture_t *R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, int textype, int flags, const unsigned int *palette);
58
59 // free a texture
60 void R_FreeTexture(rtexture_t *rt);
61
62 // update a portion of the image data of a texture, used by lightmap updates
63 // and procedural textures such as video playback.
64 void R_UpdateTexture(rtexture_t *rt, unsigned char *data, int x, int y, int width, int height);
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)) : r_texture_white->texnum)
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