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 // cg_shared.h
22 //
23 
24 #ifndef __CG_SHARED_H__
25 #define __CG_SHARED_H__
26 
27 #define CMD_BACKUP			64					// allow a lot of command backups for very fast systems
28 #define CMD_MASK			(CMD_BACKUP-1)
29 
30 #define MAX_REF_DECALS		20000
31 #define MAX_REF_DLIGHTS		32
32 #define MAX_REF_ENTITIES	2048
33 #define MAX_REF_POLYS		8192
34 
35 #define MAX_LENTS			(MAX_REF_ENTITIES/2)	// leave breathing room for normal entities
36 #define MAX_PARTICLES		8192
37 
38 /*
39 =============================================================================
40 
41 	KEYBOARD
42 
43 =============================================================================
44 */
45 
46 typedef enum keyNum_s {
47 	K_BADKEY		=	-1,
48 
49 	K_TAB			=	9,
50 	K_ENTER			=	13,
51 	K_ESCAPE		=	27,
52 	K_SPACE			=	32,
53 
54 	// normal keys should be passed as lowercased ascii
55 	K_BACKSPACE		=	127,
56 	K_UPARROW,
57 	K_DOWNARROW,
58 	K_LEFTARROW,
59 	K_RIGHTARROW,
60 
61 	K_ALT,
62 	K_CTRL,
63 
64 	K_SHIFT,
65 	K_LSHIFT,
66 	K_RSHIFT,
67 
68 	K_CAPSLOCK,
69 
70 	K_F1,
71 	K_F2,
72 	K_F3,
73 	K_F4,
74 	K_F5,
75 	K_F6,
76 	K_F7,
77 	K_F8,
78 	K_F9,
79 	K_F10,
80 	K_F11,
81 	K_F12,
82 
83 	K_INS,
84 	K_DEL,
85 	K_PGDN,
86 	K_PGUP,
87 	K_HOME,
88 	K_END,
89 
90 	K_KP_HOME		=	160,
91 	K_KP_UPARROW,
92 	K_KP_PGUP,
93 	K_KP_LEFTARROW,
94 	K_KP_FIVE,
95 	K_KP_RIGHTARROW,
96 	K_KP_END,
97 	K_KP_DOWNARROW,
98 	K_KP_PGDN,
99 	K_KP_ENTER,
100 	K_KP_INS,
101 	K_KP_DEL,
102 	K_KP_SLASH,
103 	K_KP_MINUS,
104 	K_KP_PLUS,
105 
106 	// mouse buttons generate virtual keys
107 	K_MOUSE1	=		200,
108 	K_MOUSE2,
109 	K_MOUSE3,
110 	K_MOUSE4,
111 	K_MOUSE5,
112 
113 	// joystick buttons
114 	K_JOY1,
115 	K_JOY2,
116 	K_JOY3,
117 	K_JOY4,
118 
119 	/*
120 	** aux keys are for multi-buttoned joysticks to generate so that
121 	** they can use the normal binding process
122 	*/
123 	K_AUX1,
124 	K_AUX2,
125 	K_AUX3,
126 	K_AUX4,
127 	K_AUX5,
128 	K_AUX6,
129 	K_AUX7,
130 	K_AUX8,
131 	K_AUX9,
132 	K_AUX10,
133 	K_AUX11,
134 	K_AUX12,
135 	K_AUX13,
136 	K_AUX14,
137 	K_AUX15,
138 	K_AUX16,
139 	K_AUX17,
140 	K_AUX18,
141 	K_AUX19,
142 	K_AUX20,
143 	K_AUX21,
144 	K_AUX22,
145 	K_AUX23,
146 	K_AUX24,
147 	K_AUX25,
148 	K_AUX26,
149 	K_AUX27,
150 	K_AUX28,
151 	K_AUX29,
152 	K_AUX30,
153 	K_AUX31,
154 	K_AUX32,
155 
156 	K_MWHEELDOWN,
157 	K_MWHEELUP,
158 	K_MWHEELLEFT,
159 	K_MWHEELRIGHT,
160 
161 	K_PAUSE			=	255,
162 
163 	K_MAXKEYS
164 } keyNum_t;
165 
166 typedef enum keyDest_s {
167 	KD_MINDEST		=	0,
168 
169 	KD_GAME			=	0,
170 	KD_CONSOLE		=	1,
171 	KD_MESSAGE		=	2,
172 	KD_MENU			=	3,
173 
174 	KD_MAXDEST		=	3
175 } keyDest_t;
176 
177 /*
178 =============================================================================
179 
180 	ENTITY
181 
182 =============================================================================
183 */
184 
185 #define MAX_PARSE_ENTITIES			1024
186 #define MAX_PARSEENTITIES_MASK		(MAX_PARSE_ENTITIES-1)
187 #define MAX_CLIENTWEAPONMODELS		20		// PGM -- upped from 16 to fit the chainfist vwep
188 
189 // ==========================================================================
190 
191 typedef struct frame_s {
192 	qBool					valid;			// cleared if delta parsing was invalid
193 	int						serverFrame;
194 	int						serverTime;		// server time the message is valid for (in msec)
195 	int						deltaFrame;
196 	qBool					areaChanged;
197 	byte					areaBits[MAX_AREA_BITS];		// portalarea visibility bits
198 	playerStateNew_t		playerState;
199 	int						numEntities;
200 	int						parseEntities;	// non-masked index into cg_parseEntities array
201 } frame_t;
202 
203 // ==========================================================================
204 
205 typedef struct refEntity_s {
206 	struct refModel_s		*model;			// Opaque type outside refresh
207 
208 	struct shader_s			*skin;			// NULL for inline skin
209 	int						skinNum;
210 
211 	mat3x3_t				axis;
212 
213 	// Most recent data
214 	vec3_t					origin;
215 	vec3_t					oldOrigin;
216 	int						frame;
217 	int						oldFrame;
218 	float					backLerp;		// 0.0 = current, 1.0 = old
219 
220 	bvec4_t					color;
221 	float					shaderTime;
222 
223 	int						flags;
224 	float					scale;
225 } refEntity_t;
226 
227 /*
228 =============================================================================
229 
230 	DLIGHTS
231 
232 =============================================================================
233 */
234 
235 typedef struct refDLight_s {
236 	vec3_t					origin;
237 
238 	vec3_t					color;
239 	float					intensity;
240 
241 	vec3_t					mins;
242 	vec3_t					maxs;
243 } refDLight_t;
244 
245 typedef struct refLightStyle_s {
246 	float					rgb[3];			// 0.0 - 2.0
247 	float					white;			// highest of rgb
248 } refLightStyle_t;
249 
250 /*
251 =============================================================================
252 
253 	EFFECTS
254 
255 =============================================================================
256 */
257 
258 typedef struct refPoly_s {
259 	int						numVerts;
260 
261 	vec3_t					origin;
262 	float					radius;
263 
264 	vec3_t					*vertices;
265 	vec2_t					*texCoords;
266 	bvec4_t					*colors;
267 
268 	struct shader_s			*shader;
269 	float					shaderTime;
270 } refPoly_t;
271 
272 typedef struct refDecal_s {
273 	// Rendering data
274 	uint32					numIndexes;
275 	int						*indexes;
276 
277 	vec3_t					*normals;
278 
279 	refPoly_t				poly;			// This data should *not* be touched by CGame, R_Create/Free/AddDecal handle this data.
280 
281 	// For culling
282 	uint32					numSurfaces;
283 	struct mBspSurface_s	**surfaces;
284 
285 	vec3_t					origin;
286 	float					radius;
287 } refDecal_t;
288 
289 /*
290 =============================================================================
291 
292 	GUI INFORMATION
293 
294 =============================================================================
295 */
296 
297 typedef enum guiVarType_s {
298 	GVT_FLOAT,
299 	GVT_STR,
300 	GVT_STR_PTR,
301 	GVT_VEC
302 } guiVarType_t;
303 
304 /*
305 =============================================================================
306 
307 	REFRESH DEFINITION
308 
309 =============================================================================
310 */
311 
312 typedef struct refConfig_s {
313 	// Gamma ramp
314 	qBool					hwGammaAvail;
315 	qBool					hwGammaInUse;
316 
317 	// Extensions
318 	qBool					extArbMultitexture;
319 	qBool					extBGRA;
320 	qBool					extCompiledVertArray;
321 	qBool					extDrawRangeElements;
322 	qBool					extFragmentProgram;
323 	qBool					extNVTexEnvCombine4;
324 	qBool					extSGISGenMipmap;
325 	qBool					extSGISMultiTexture;
326 	qBool					extStencilTwoSide;
327 	qBool					extStencilWrap;
328 	qBool					extTex3D;
329 	qBool					extTexCompression;
330 	qBool					extTexCubeMap;
331 	qBool					extTexEdgeClamp;
332 	qBool					extTexEnvAdd;
333 	qBool					extTexEnvCombine;
334 	qBool					extTexEnvDot3;
335 	qBool					extTexFilterAniso;
336 	qBool					extVertexBufferObject;
337 	qBool					extVertexProgram;
338 	qBool					extWinSwapInterval;
339 
340 	// GL Queries
341 	int						max3DTexSize;
342 	int						maxAniso;
343 	int						maxCMTexSize;
344 	int						maxElementVerts;
345 	int						maxElementIndices;
346 	int						maxTexCoords;
347 	int						maxTexImageUnits;
348 	int						maxTexSize;
349 	int						maxTexUnits;
350 
351 	// Video
352 	int						vidWidth;
353 	int						vidHeight;
354 	qBool					vidFullScreen;
355 	int						vidFrequency;
356 	int						vidBitDepth;
357 	qBool					stereoEnabled;
358 } refConfig_t;
359 
360 // ==========================================================================
361 
362 typedef struct refDef_s {
363 	float					time;				// time is used to auto animate
364 
365 	int						x, y;
366 	int						width, height;
367 
368 	float					fovX, fovY;
369 
370 	vec3_t					viewOrigin;
371 	vec3_t					velocity;			// primarily used for the audio system
372 
373 	vec3_t					viewAngles;
374 	mat3x3_t				viewAxis;			// Forward, left, up
375 	vec3_t					rightVec;			// opposite of viewAxis[1]
376 
377 	int						rdFlags;			// RDF_NOWORLDMODEL, etc
378 
379 	qBool					areaChanged;
380 	byte					*areaBits;			// if not NULL, only areas with set bits will be drawn
381 } refDef_t;
382 
383 #endif // __CG_SHARED_H__
384