1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 
20 //
21 // rf_image.h
22 //
23 
24 /*
25 =============================================================================
26 
27 	IMAGING
28 
29 =============================================================================
30 */
31 
32 enum { // texUnit_t
33 	TEXUNIT0,
34 	TEXUNIT1,
35 	TEXUNIT2,
36 	TEXUNIT3,
37 	TEXUNIT4,
38 	TEXUNIT5,
39 	TEXUNIT6,
40 	TEXUNIT7,
41 
42 	MAX_TEXUNITS
43 };
44 
45 enum { // texFlags_t
46 	IT_3D				= 1 << 0,		// 3d texture
47 	IT_CUBEMAP			= 1 << 1,		// it's a cubemap env base image
48 	IT_LIGHTMAP			= 1 << 2,		// lightmap texture
49 
50 	IF_CLAMP			= 1 << 3,		// texcoords edge clamped
51 	IF_NOCOMPRESS		= 1 << 4,		// no texture compression
52 	IF_NOGAMMA			= 1 << 5,		// not affected by vid_gama
53 	IF_NOINTENS			= 1 << 6,		// not affected by intensity
54 	IF_NOMIPMAP_LINEAR	= 1 << 7,		// not mipmapped, linear filtering
55 	IF_NOMIPMAP_NEAREST	= 1 << 8,		// not mipmapped, nearest filtering
56 	IF_NOPICMIP			= 1 << 9,		// not affected by gl_picmip
57 	IF_NOFLUSH			= 1 << 10,		// do not flush at the end of registration (internal only)
58 	IF_NOALPHA			= 1 << 11,		// force alpha to 255
59 	IF_NORGB			= 1 << 12,		// force rgb to 255 255 255
60 };
61 
62 typedef struct image_s {
63 	char					name[MAX_QPATH];				// game path, including extension
64 	char					bareName[MAX_QPATH];			// filename only, as called when searching
65 
66 	int						width,		upWidth;			// source image
67 	int						height,		upHeight;			// after power of two and picmip
68 	int						depth,		upDepth;			// for 3d textures
69 	texFlags_t				flags;
70 
71 	int						tcWidth,	tcHeight;			// special case for high-res texture scaling
72 
73 	int						target;							// destination for binding
74 	int						format;							// uploaded texture color components
75 
76 	uint32					touchFrame;						// free if this doesn't match the current frame
77 	uint32					texNum;							// gl texture binding, r_numImages + 1, can't be 0
78 	uint32					visFrame;						// frame this texture was last used in
79 
80 	uint32					hashValue;						// calculated hash value
81 	struct image_s			*hashNext;						// hash image tree
82 } image_t;
83 
84 #define MAX_IMAGES			1024			// maximum local images
85 extern uint32				r_numImages;
86 
87 #define FOGTEX_WIDTH		256
88 #define FOGTEX_HEIGHT		32
89 
90 #define Q2LIGHTMAP_WIDTH	256				// lightmaps are square
91 #define R_MAX_LIGHTMAPS		128				// maximum local lightmap textures
92 extern image_t		*r_lmTextures[R_MAX_LIGHTMAPS];
93 
94 extern const char	*r_skyNameSuffix[6];
95 extern const char	*r_cubeMapSuffix[6];
96 
97 //
98 // rf_image.c
99 //
100 
101 void	GL_TextureBits (qBool verbose, qBool verboseOnly);
102 void	GL_TextureMode (qBool verbose, qBool verboseOnly);
103 
104 void	GL_ResetAnisotropy (void);
105 
106 #define R_Load2DImage(name,pic,width,height,flags,samples)			R_LoadImage((name),NULL,(pic),(width),(height),1,(flags),(samples),qFalse,qFalse)
107 #define R_Load3DImage(name,pic,width,height,depth,flags,samples)	R_LoadImage((name),NULL,(pic),(width),(height),(depth),(flags),(samples),qFalse,qFalse)
108 
109 image_t	*R_LoadImage (char *name, const char *bareName, byte **pic, int width, int height, int depth, texFlags_t flags, int samples, qBool upload8, qBool isPCX);
110 
111 #define R_TouchImage(img) ((img)->touchFrame = ri.reg.registerFrame, ri.reg.imagesTouched++)
112 
113 image_t	*R_RegisterImage (char *name, texFlags_t flags);
114 
115 void	R_BeginImageRegistration (void);
116 void	R_EndImageRegistration (void);
117 
118 void	R_UpdateGammaRamp (void);
119 
120 void	R_ImageInit (void);
121 void	R_ImageShutdown (void);
122