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