1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19*/
20
21// refresh.h -- public interface to refresh functions
22
23#define	TOP_RANGE		16			// soldier uniform colors
24#define	BOTTOM_RANGE	96
25
26//=============================================================================
27
28typedef struct efrag_s
29{
30	struct mleaf_s		*leaf;
31	struct efrag_s		*leafnext;
32	struct entity_s		*entity;
33	struct efrag_s		*entnext;
34} efrag_t;
35
36
37typedef struct entity_s
38{
39	int						keynum;			// for matching entities in different frames
40	vec3_t					origin;
41	vec3_t					angles;
42	struct model_s			*model;			// NULL = no model
43	int						frame;
44	byte					*colormap;
45	int						skinnum;		// for Alias models
46
47	struct player_info_s	*scoreboard;	// identify player
48
49	float					syncbase;
50
51	struct efrag_s			*efrag;			// linked list of efrags (FIXME)
52	int						visframe;		// last frame this entity was
53											// found in an active leaf
54											// only used for static objects
55
56	int						dlightframe;	// dynamic lighting
57	int						dlightbits;
58
59// FIXME: could turn these into a union
60	int						trivial_accept;
61	struct mnode_s			*topnode;		// for bmodels, first world node
62											//  that splits bmodel, or NULL if
63											//  not split
64} entity_t;
65
66// !!! if this is changed, it must be changed in asm_draw.h too !!!
67typedef struct
68{
69	vrect_t		vrect;				// subwindow in video for refresh
70									// FIXME: not need vrect next field here?
71	vrect_t		aliasvrect;			// scaled Alias version
72	int			vrectright, vrectbottom;	// right & bottom screen coords
73	int			aliasvrectright, aliasvrectbottom;	// scaled Alias versions
74	float		vrectrightedge;			// rightmost right edge we care about,
75										//  for use in edge list
76	float		fvrectx, fvrecty;		// for floating-point compares
77	float		fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
78	int			vrect_x_adj_shift20;	// (vrect.x + 0.5 - epsilon) << 20
79	int			vrectright_adj_shift20;	// (vrectright + 0.5 - epsilon) << 20
80	float		fvrectright_adj, fvrectbottom_adj;
81										// right and bottom edges, for clamping
82	float		fvrectright;			// rightmost edge, for Alias clamping
83	float		fvrectbottom;			// bottommost edge, for Alias clamping
84	float		horizontalFieldOfView;	// at Z = 1.0, this many X is visible
85										// 2.0 = 90 degrees
86	float		xOrigin;			// should probably allways be 0.5
87	float		yOrigin;			// between be around 0.3 to 0.5
88
89	vec3_t		vieworg;
90	vec3_t		viewangles;
91
92	float		fov_x, fov_y;
93
94	int			ambientlight;
95} refdef_t;
96
97
98//
99// refresh
100//
101extern	int		reinit_surfcache;
102
103
104extern	refdef_t	r_refdef;
105extern vec3_t	r_origin, vpn, vright, vup;
106
107extern	struct texture_s	*r_notexture_mip;
108
109extern	entity_t	r_worldentity;
110
111void R_Init (void);
112void R_InitTextures (void);
113void R_InitEfrags (void);
114void R_RenderView (void);		// must set r_refdef first
115void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
116								// called whenever r_refdef or vid change
117void R_InitSky (struct texture_s *mt);	// called at level load
118
119void R_AddEfrags (entity_t *ent);
120void R_RemoveEfrags (entity_t *ent);
121
122void R_NewMap (void);
123
124
125void R_ParseParticleEffect (void);
126void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
127void R_RocketTrail (vec3_t start, vec3_t end, int type);
128
129void R_EntityParticles (entity_t *ent);
130void R_BlobExplosion (vec3_t org);
131void R_ParticleExplosion (vec3_t org);
132void R_LavaSplash (vec3_t org);
133void R_TeleportSplash (vec3_t org);
134
135void R_PushDlights (void);
136void R_InitParticles (void);
137void R_ClearParticles (void);
138void R_DrawParticles (void);
139void R_DrawWaterSurfaces (void);
140
141
142//
143// surface cache related
144//
145extern	int		reinit_surfcache;	// if 1, surface cache is currently empty and
146extern qboolean	r_cache_thrash;	// set if thrashing the surface cache
147
148int	D_SurfaceCacheForRes (int width, int height);
149void D_FlushCaches (void);
150void D_DeleteSurfaceCache (void);
151void D_InitCaches (void *buffer, int size);
152void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
153
154