1 //----------------------------------------------------------------------------- 2 // Texture 3 //----------------------------------------------------------------------------- 4 5 #ifndef __TEXTURE_H__ 6 #define __TEXTURE_H__ 7 8 #include "files.h" 9 10 /** 11 * Adjust color, currently only overbright is used. 12 */ 13 void AdjustColor(texinfo *t, float overbright, float gamma, float lightness); 14 15 /** 16 * Given a texrefs, loads the texture, sends it to the driver and delete it. 17 * @param tr the texture reference to load. 18 */ 19 void LoadTexture(TexRefs *tr); 20 21 /** 22 * Load a TGA. 23 */ 24 void TGA_Decode(VFile *vf, texinfo *tex); 25 26 /** 27 * Load a JPG. 28 */ 29 void JPG_Decode(VFile *vf, texinfo *tex); 30 31 /** 32 * Load a WAL. 33 */ 34 void WAL_Decode(VFile *vf, texinfo *tex); 35 36 /** 37 * Loads the default texture. 38 * @param t The destination texture. 39 * @todo Use a better default texture, this looks jerky 40 */ 41 void LoadDefaultTex(texinfo *t); 42 43 /** 44 * Flips a texture vertically. 45 * @param tex The texture to be flipped. 46 */ 47 void FlipTexture(texinfo *tex); 48 49 /** 50 * Texture manager. 51 * The texture manager provides all mechanisms to load and create textures. The 52 * manager supports following texture types: 53 * - TGA (8, 16, 24, 32 bits) 54 * - JPG 55 * - WAL 56 * @todo Instead of using a fixed size array, we could use a grow array, 57 * note that we need inmediate aleatory acces. 58 * @bug When a shader or a texture is not found, the engine crashes during map 59 * unload. Try changing a shader name (required by the map) and launch the 60 * engine. 61 */ 62 class TextureManager 63 { 64 public: 65 66 TextureManager(int num = 1024); 67 ~TextureManager(void); 68 69 /** 70 * Increases a texinfo count, if already loaded, or reserves it if not loaded. 71 */ 72 texinfo *AddTexinfo(const char *name, int flags); 73 74 /** 75 * Decreases count of the given texinfo. 76 * @param info the texinfo to decrement 77 */ 78 void DeleteTexinfo(texinfo *info); 79 80 /** 81 * Reset all the counters. 82 */ 83 void ResetAll(void); 84 85 /** 86 * Loads unloaded textures, deletes unreferenced textures. 87 */ 88 void Update(void); 89 90 private: 91 92 TexRefs *texrefs; 93 int max_refs; 94 int num_refs; 95 }; 96 97 #endif /* __TEXTURE_H__ */ 98