1 #ifndef _OGL_TEXTURE_DEF_
2 #define _OGL_TEXTURE_DEF_
3 /*
4 
5 	Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
6 	and the "Aleph One" developers.
7 
8 	This program is free software; you can redistribute it and/or modify
9 	it under the terms of the GNU General Public License as published by
10 	the Free Software Foundation; either version 3 of the License, or
11 	(at your option) any later version.
12 
13 	This program is distributed in the hope that it will be useful,
14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 	GNU General Public License for more details.
17 
18 	This license is contained in the file "COPYING",
19 	which is included with this source code; it is available online at
20 	http://www.gnu.org/licenses/gpl.html
21 
22 	OpenGL Texture-Definition File
23 	by Loren Petrich,
24 	May 11, 2003
25 
26 	This contains the "base" definitions of the OpenGL textures,
27 	which are used both for wall/sprite substitutions and for
28 	model skins.
29 */
30 
31 
32 #include <vector>
33 
34 #include "shape_descriptors.h"
35 #include "ImageLoader.h"
36 
37 #ifdef HAVE_OPENGL
38 
39 
40 /*
41 	Since Apple OpenGL currently does not support indexed-color images in direct-color
42 	rendering, it's necessary to keep track of all possible images separately, and this means
43 	not only all possible color tables, but also infravision and silhouette images.
44 	OpenGL 1.2 will change all of that, however :-)
45 */
46 
47 enum {
48 	// The bitmap sets for the different color tables do not need to be listed
49 	INFRAVISION_BITMAP_SET = MAXIMUM_CLUTS_PER_COLLECTION,
50 	SILHOUETTE_BITMAP_SET,
51 	INFRAVISION_BITMAP_CLUTSPECIFIC,
52 	SILHOUETTE_BITMAP_CLUTSPECIFIC = 2*MAXIMUM_CLUTS_PER_COLLECTION + 2,
53 	NUMBER_OF_OPENGL_BITMAP_SETS = 3*MAXIMUM_CLUTS_PER_COLLECTION + 2
54 };
55 
56 enum {
57     // The definitions for clut variants (used in texture and model MML)
58 	ALL_CLUT_VARIANTS = -1,
59 	CLUT_VARIANT_NORMAL = 0,
60 	CLUT_VARIANT_INFRAVISION,
61 	CLUT_VARIANT_SILHOUETTE,
62 	NUMBER_OF_CLUT_VARIANTS
63 };
64 
65 
66 // Check for infravision or silhouette special CLUTs
IsInfravisionTable(short CLUT)67 static inline bool IsInfravisionTable(short CLUT)
68 {
69     return (CLUT == INFRAVISION_BITMAP_SET ||
70             (CLUT >= INFRAVISION_BITMAP_CLUTSPECIFIC &&
71              CLUT <  INFRAVISION_BITMAP_CLUTSPECIFIC + MAXIMUM_CLUTS_PER_COLLECTION));
72 }
IsSilhouetteTable(short CLUT)73 static inline bool IsSilhouetteTable(short CLUT)
74 {
75     return (CLUT == SILHOUETTE_BITMAP_SET ||
76             (CLUT >= SILHOUETTE_BITMAP_CLUTSPECIFIC &&
77              CLUT <  SILHOUETTE_BITMAP_CLUTSPECIFIC + MAXIMUM_CLUTS_PER_COLLECTION));
78 }
79 
80 
81 // If the color-table value has this value, it means all color tables:
82 const int ALL_CLUTS = -1;
83 
84 
85 // Here are the texture-opacity types.
86 // Opacity is the value of the alpha channel, sometimes called transparency
87 enum
88 {
89 	OGL_OpacType_Crisp,		// The default: crisp edges, complete opacity
90 	OGL_OpacType_Flat,		// Fuzzy edges, but with flat opacity
91 	OGL_OpacType_Avg,		// Fuzzy edges, and opacity = average(color channel values)
92 	OGL_OpacType_Max,		// Fuzzy edges, and opacity = max(color channel values)
93 	OGL_NUMBER_OF_OPACITY_TYPES
94 };
95 
96 // Here are the texture-blend types
97 enum
98 {
99 	OGL_BlendType_Crossfade,	// The default: crossfade from background to texture value
100 	OGL_BlendType_Add,			// Add texture value to background
101 	OGL_BlendType_Crossfade_Premult,
102 	OGL_BlendType_Add_Premult,
103 	OGL_NUMBER_OF_BLEND_TYPES,
104 	OGL_FIRST_PREMULT_ALPHA = OGL_BlendType_Crossfade_Premult
105 };
106 
107 // Shared options for wall/sprite textures and for skins
108 struct OGL_TextureOptionsBase
109 {
110 	short OpacityType;		// Which type of opacity to use?
111 	float OpacityScale;		// How much to scale the opacity
112 	float OpacityShift;		// How much to shift the opacity
113 	bool Substitution;              // Is this a substitute texture?
114 
115 	// Names of files to load; these will be extended ones with directory specifications
116 	// <dirname>/<dirname>/<filename>
117 	FileSpecifier NormalColors, NormalMask, GlowColors, GlowMask, OffsetMap;
118 
119 	// the image is premultiplied
120 	bool NormalIsPremultiplied, GlowIsPremultiplied;
121 
122 	// hints passed into loadfromfile, in case file dimensions are POT
123 	short actual_height, actual_width;
124 
125 	// what kind of texture this is, for texture quality purposes
126 	short Type;
127 
128 	// Normal and glow-mapped images
129 	ImageDescriptor NormalImg, GlowImg, OffsetImg;
130 
131 	// Normal and glow blending
132 	short NormalBlend, GlowBlend;
133 
134 	// Bloom controls, for normal and glow images
135 	float BloomScale;
136 	float BloomShift;
137 	float GlowBloomScale;
138 	float GlowBloomShift;
139 	float LandscapeBloom;
140 
141 	// Glow modulated using max of normal lighting intensity and this value
142 	float MinGlowIntensity;
143 
144 	// For convenience
145 	void Load();
146 	void Unload();
147 
148 	virtual int GetMaxSize();
149 
OGL_TextureOptionsBaseOGL_TextureOptionsBase150 	OGL_TextureOptionsBase():
151 	OpacityType(OGL_OpacType_Crisp), OpacityScale(1), OpacityShift(0),
152 		NormalBlend(OGL_BlendType_Crossfade), GlowBlend(OGL_BlendType_Crossfade), Substitution(false), NormalIsPremultiplied(false), GlowIsPremultiplied(false), actual_height(0), actual_width(0), Type(-1), BloomScale(0), BloomShift(0), GlowBloomScale(1), GlowBloomShift(0), LandscapeBloom(0.5), MinGlowIntensity(1)
153 		{}
154 };
155 
156 #endif
157 
158 #endif
159 
160