1 /**
2  * @file
3  * @brief
4  */
5 
6 /*
7 All original material Copyright (C) 2002-2013 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 
24 */
25 
26 #pragma once
27 
28 #include "r_gl.h"
29 #include "r_material.h"
30 /*
31 skins will be outline flood filled and mip mapped
32 pics and sprites with alpha will be outline flood filled
33 pic won't be mip mapped
34 
35 model skin
36 sprite frame
37 wall texture
38 pic
39 */
40 
41 typedef enum {
42 	it_chars,
43 	it_effect,
44 	it_static,
45 	it_pic,
46 	it_wrappic,
47 	it_skin,
48 	it_normalmap,
49 	it_glowmap,
50 	it_specularmap,
51 	it_roughnessmap,
52 
53 	/** the following are freed with every mapchange */
54 	it_world,
55 	it_lightmap,
56 	it_deluxemap,
57 	it_material,
58 	it_worldrelated
59 } imagetype_t;
60 
61 typedef struct image_s {
62 	char name[MAX_QPATH];				/**< game path, including extension, must be first */
63 	imagetype_t type;
64 	int width, height;					/**< source image dimensions */
65 	int upload_width, upload_height;	/**< dimensions after power of two and picmip */
66 	GLuint texnum;						/**< gl texture binding */
67 	bool has_alpha;
68 	material_t material;
69 	struct image_s* normalmap;			/**< normalmap texture  */
70 	struct image_s* glowmap;			/**< glowmap texture  */
71 	struct image_s* specularmap;		/**< specularity texture (for reflection color) */
72 	struct image_s* roughnessmap;		/**< roughness texture (for Cook-Torrance shading) */
73 	struct image_s* hash_next;			/**< hash map next pointer in case of collision */
74 } image_t;
75 
76 #define MAX_GL_TEXTURES		1024
77 #define MAX_GL_LIGHTMAPS	256
78 #define MAX_GL_DELUXEMAPS	256
79 #define MAX_GL_FRAMEBUFFERS	256
80 
81 extern int r_numImages;
82 
83 void R_UploadTexture(const unsigned *data, int width, int height, image_t* image);
84 void R_SoftenTexture(byte* in, int width, int height, int bpp);
85 void R_GetScaledTextureSize(int width, int height, int* scaledWidth, int* scaledHeight);
86 void R_ScaleTexture(const unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight);
87 image_t* R_RenderToTexture(const char* name, int x, int y, int w, int h);
88 
89 void R_ImageList_f(void);
90 void R_InitImages(void);
91 void R_ShutdownImages(void);
92 void R_ReloadImages (void);
93 void R_FreeWorldImages(void);
94 void R_ImageClearMaterials(void);
95 void R_UploadAlpha(const image_t* image, const byte* alphaData);
96 void R_TextureMode(const char* string);
97 void R_TextureAlphaMode(const char* string);
98 void R_TextureSolidMode(const char* string);
99 
100 void R_FreeImage(image_t* image);
101 
102 image_t* R_LoadImageData(const char* name, const byte* pic, int width, int height, imagetype_t type);
103 image_t* R_GetImage(const char* name);
104 image_t* R_FindImage(const char* pname, imagetype_t type);
105 const image_t* R_FindPics(const char* name);
106 
107 bool R_ImageExists(const char* pname, ...) __attribute__((format(__printf__, 1, 2)));
108 image_t* R_GetImageAtIndex(int i);
109 int R_GetImageIndex(image_t* image);
110 
111 #define MAX_ENVMAPTEXTURES 2
112 extern image_t* r_envmaptextures[MAX_ENVMAPTEXTURES];
113 
114 #define NUM_FLARETEXTURES 10
115 extern image_t* r_flaretextures[NUM_FLARETEXTURES];
116 
117 extern image_t* shadow;				/**< draw this when actor is alive */
118 extern image_t* r_noTexture;
119 extern image_t* r_warpTexture;
120 extern image_t* r_dummyTexture; 	/**< 1x1 pixel white texture to be used when texturing is required, but texture is not available */
121