File: ref.h

package info (click to toggle)
alien-arena 7.66%2Bdfsg-5
  • links: PTS, VCS
  • area: contrib
  • in suites: buster
  • size: 9,664 kB
  • sloc: ansic: 113,704; cpp: 41,133; sh: 4,507; makefile: 546; ruby: 438
file content (441 lines) | stat: -rw-r--r-- 10,034 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/
#ifndef __REF_H
#define __REF_H

#include "qcommon/qcommon.h"

#define DIV254BY255 (0.9960784313725490196078431372549f)
#define DIV255 (0.003921568627450980392156862745098f)
#define DIV256 (0.00390625f)
#define DIV512 (0.001953125f)

#define	MAX_DLIGHTS			32
#define	MAX_ENTITIES		256 //was 128 - use of static meshes necessitates an increase.
#define	MAX_PARTICLES		8192
#define	MAX_LIGHTSTYLES		256

#define MAX_FLARES      512
#define MAX_GRASSES		2048
#define MAX_BEAMS		128

typedef struct
{
	vec3_t origin;
	vec3_t color;
	int size;
	int style;
	float alpha;
	float time;
	int leafnum;
} flare_t;

typedef struct
{
	int type;
	vec3_t origin;
	vec3_t color;
	float size;
	int texsize;
	int texnum;
	char name[MAX_QPATH];
	int leafnum;
	qboolean sunVisible; //can cast shadows in sunlight
	vec3_t static_light;
} grass_t;

typedef struct
{
	int type;
	vec3_t origin;
	vec3_t color;
	float size;
	float xang;
	float yang;
	qboolean rotating;
	int texsize;
	int texnum;
	char name[MAX_QPATH];
	int leafnum;
	int leafnum2;
} beam_t;

#define SHELL_RED_COLOR		0xF2
#define SHELL_GREEN_COLOR	0xD0
#define SHELL_BLUE_COLOR	0xF3

#define SHELL_RG_COLOR		0xDC
//#define SHELL_RB_COLOR		0x86
#define SHELL_RB_COLOR		0x68
#define SHELL_BG_COLOR		0x78

//ROGUE
#define SHELL_DOUBLE_COLOR	0xDF // 223
#define	SHELL_HALF_DAM_COLOR	0x90
#define SHELL_CYAN_COLOR	0x72
//ROGUE

#define SHELL_WHITE_COLOR	0xD7

#define PARTICLE_NONE				0
#define PARTICLE_STANDARD			1
#define PARTICLE_BEAM				2
#define PARTICLE_DECAL				3
#define PARTICLE_FLAT				4
#define PARTICLE_WEATHER			5
#define PARTICLE_FLUTTERWEATHER     6
#define PARTICLE_RAISEDDECAL		7
#define PARTICLE_ROTATINGYAW		8
#define PARTICLE_ROTATINGROLL		9
#define PARTICLE_ROTATINGYAWMINUS   10
#define PARTICLE_VERT				11
#define PARTICLE_CHAINED            12

#define RDF_BLOOM         4      //BLOOMS

#define	MAX_VERTEX_CACHES	4096
#define MAX_VBO_XYZs		65536

typedef enum {
	VBO_STATIC,
	VBO_DYNAMIC
} vertCacheMode_t;

typedef enum {
	VBO_STORE_ANY,
	VBO_STORE_XYZ,
	VBO_STORE_INDICES,
	VBO_STORE_ST,
	VBO_STORE_NORMAL,
	VBO_STORE_BINORMAL,
	VBO_STORE_TANGENT
} vertStoreMode_t;

typedef struct vertCache_s
{
	struct vertCache_s	*prev;
	struct vertCache_s	*next;

	vertCacheMode_t		mode;

	int					size;

	void				*pointer;

	vertStoreMode_t		store;
	struct model_s		*mod;

	unsigned			id;
} vertCache_t;

typedef struct {
	vertCache_t		*freeVertCache;
	vertCache_t		activeVertCache;
	vertCache_t		vertCacheList[MAX_VERTEX_CACHES];
} vertCacheManager_t;

vertCacheManager_t	vcm;

typedef struct entity_s
{
	char	name[MAX_QPATH];

	struct model_s		*model;			// opaque type outside refresh
	struct model_s		*lod1;
	struct model_s		*lod2;

	float				angles[3];

	/*
	** most recent data
	*/
	float				origin[3];
	int					frame;

	/*
	** previous data for lerping
	*/
	float				oldorigin[3];
	int					oldframe;

	/*
	** frame and timestamp (iqm lerping)
	*/
	float				frametime;
	int					prevframe;

	/*
	** misc
	*/
	float	backlerp;				// 0.0 = current, 1.0 = old
	int		skinnum;

	int		lightstyle;				// for flashing entities
	float	alpha;					// ignore if RF_TRANSLUCENT isn't set

	struct image_s	*skin;			// NULL for inline skin
	int		flags;

	int		team;

	float	bob;
	
	int		number; //edict number;

	struct rscript_s *script;

} entity_t;

//for saving persistent data about entities across frames
typedef struct {
	/*
	** for saving non-dynamic lighting of static meshes
	*/
	qboolean			setlightstuff;
	float				oldnumlights;
	vec3_t				oldlightadd;
	vec3_t				oldorigin;
	float				oldlightintens;
} cl_entity_pers_t;

cl_entity_pers_t	cl_persistent_ents[MAX_EDICTS];


#define ENTITY_FLAGS  68

typedef struct
{
	vec3_t	origin;
	vec3_t	color;
	float	intensity;
} dlight_t;

typedef struct
{
	float	strength;
	vec3_t	direction;
	vec3_t	color;
} m_dlight_t;

// ========
// PGM
typedef struct
{
	qboolean	isactive;

	vec3_t		lightcol;
	float		light;
	float		lightvel;
} cplight_t;

#define P_LIGHTS_MAX 8

typedef struct particle_s
{
	struct particle_s	*next;

	cplight_t	lights[P_LIGHTS_MAX];

	float		time;

	vec3_t		org;
	vec3_t		angle;
	vec3_t		vel;
	vec3_t		accel;
	vec3_t		end;
	float		color;
	float		colorvel;
	float		alpha;
	float		alphavel;
	int			type;		// 0 standard, 1 smoke, etc etc...
	struct image_s *image;
	int			blenddst;
	int			blendsrc;
	float		scale;
	float		scalevel;
	qboolean	fromsustainedeffect;
	float       dist;

	// These are computed from the foo and foovel values-- for example,
	// current_color is computed from color and colorvel and its value
	// changes every frame.
	vec3_t	current_origin;
	int		current_color;
	float	current_alpha;
	float	current_scale;

	// For particle chains-- the particle renderer will automatically play
	// connect-the-dots with these.
	struct particle_s	*chain_prev;
	vec3_t				current_pspan;

} particle_t;


typedef struct
{
	float		rgb[3];			// 0.0 - 2.0
	float		white;			// highest of rgb
} lightstyle_t;

typedef struct
{
	int			x, y, width, height;// in virtual screen coordinates
	float		fov_x, fov_y;
	float		vieworg[3];
	float		viewangles[3];
	float		blend[4];			// rgba 0-1 full screen blend
	float		time;				// time is uesed to auto animate
	int			rdflags;			// RDF_UNDERWATER, etc

	byte		*areabits;			// must not be NULL if you want to do BSP rendering
	qboolean	areabits_changed;

	lightstyle_t	*lightstyles;	// [MAX_LIGHTSTYLES]

	int			num_entities;
	entity_t	*entities;

	int			num_viewentities;
	entity_t	*viewentities;

	int			num_dlights;
	dlight_t	*dlights;
	qboolean	dlights_changed;
	int			num_dlight_surfaces;

	int			num_particles;
	particle_t	**particles;

	int			num_grasses;
	grass_t		*grasses;

	int			num_beams;
	beam_t		*beams;
	
	// Because the mirror texture doesn't have to updatea more than 60 times
	// per second.
	int			last_mirrorupdate_time; // in ms

} refdef_t;

//
// view origin moved from r_local.h. -M.
//
extern	vec3_t	vup;
extern	vec3_t	vpn;
extern	vec3_t	vright;
extern	vec3_t	r_origin;

// Knightmare- added Psychospaz's menu cursor
//cursor - psychospaz
#define MENU_CURSOR_BUTTON_MAX 2

typedef struct
{
	//only 2 buttons for menus
	float		buttontime[MENU_CURSOR_BUTTON_MAX];
	int			buttonclicks[MENU_CURSOR_BUTTON_MAX];
	qboolean	buttonused[MENU_CURSOR_BUTTON_MAX];
	qboolean	buttondown[MENU_CURSOR_BUTTON_MAX];

	qboolean	mouseaction;

	//this is the active item that cursor is on.
	int			menulayer;
	struct _tag_menuitem
				*menuitem;
	//this is whatever menuitem it was on when a click-and-drag maneuver was
	//begun.
	struct _tag_menuitem
				*click_menuitem;
	qboolean	suppress_drag; //started clicking with nothing selected

	//coords
	int		x;
	int		y;

	int		oldx;
	int		oldy;
} cursor_t;

float *RGBA (float r, float g, float b, float a);
#define RGBA8(a,b,c,d) RGBA((a)/255.0f, (b)/255.0f, (c)/255.0f, (d)/255.0f)

qboolean	Draw_PicExists (const char *name);
void	Draw_GetPicSize (int *w, int *h, const char *name);
void	Draw_Pic (float x, float y, const char *name);
void	Draw_ScaledPic (float x, float y, float scale, const char *pic);
void	Draw_StretchPic (float x, float y, float w, float h, const char *name);
void	Draw_AlphaStretchTilingPic (float x, float y, float w, float h, const char *name, float alphaval);
void	Draw_AlphaStretchPic (float x, float y, float w, float h, const char *name, float alphaval);
void	Draw_AlphaStretchPlayerIcon (int x, int y, int w, int h, const char *pic, float alphaval);
void	Draw_Fill (float x, float y, float w, float h, const float rgba[]);
void	Draw_FadeScreen (void);

void	R_BeginFrame( float camera_separation );
void	R_SwapBuffers( int );
void	R_SetPalette ( const unsigned char *palette);

struct model_s	*R_RegisterModel (char *name);
struct image_s	*R_RegisterSkin (char *name);
struct image_s	*R_RegisterPic (const char *name);

void	R_SetSky (char *name, float rotate, vec3_t axis);

void	R_RegisterBasePlayerModels(void);
void	R_RegisterCustomPlayerModels(void);
void	S_RegisterSoundsForPlayer (char *playername);
void	R_BeginRegistration (char *map);
void	R_EndRegistration (void);

void	R_RenderFrame (refdef_t *fd);
void	R_RenderFramePlayerSetup (refdef_t *fd);
void	R_EndFrame (void);

int		R_Init( void *hinstance, void *hWnd );
void	R_Shutdown (void);

void	R_AppActivate( qboolean active );

// TrueType
struct ttf_font_s;
typedef struct ttf_font_s * ttf_font_t;

ttf_font_t TTF_GetFont( const char * name , unsigned int size );
void TTF_GetSize( ttf_font_t font , const char * text , unsigned int * width , unsigned int * height );
void TTF_RawPrint( ttf_font_t font , const char * text , float x , float y , const float color[4] );

#define MAX_RADAR_ENTS 512
typedef struct RadarEnt_s{
  float color[4];
  vec3_t org;
}RadarEnt_t;


extern int numRadarEnts;
extern RadarEnt_t RadarEnts[MAX_RADAR_ENTS];

extern cursor_t cursor;


qboolean is_localhost; //because ref_gl can't access cls.servername.

#endif // __REF_H