1 /*
2 	d_iface.h
3 
4 	Interface header file for rasterization driver modules
5 
6 	Copyright (C) 1996-1997  Id Software, Inc.
7 
8 	This program is free software; you can redistribute it and/or
9 	modify it under the terms of the GNU General Public License
10 	as published by the Free Software Foundation; either version 2
11 	of the License, or (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.
16 
17 	See the GNU General Public License for more details.
18 
19 	You should have received a copy of the GNU General Public License
20 	along with this program; if not, write to:
21 
22 		Free Software Foundation, Inc.
23 		59 Temple Place - Suite 330
24 		Boston, MA  02111-1307, USA
25 
26 */
27 
28 #ifndef _D_IFACE_H
29 #define _D_IFACE_H
30 
31 #include "QF/iqm.h"
32 #include "QF/mathlib.h"
33 #include "QF/model.h"
34 #include "QF/render.h"
35 #include "QF/vid.h"
36 
37 #define WARP_WIDTH		320
38 #define WARP_HEIGHT		200
39 
40 #define MAX_LBM_HEIGHT	1024
41 
42 typedef struct {
43 	struct tex_s **skins;
44 	iqmblend_t *blend_palette;	// includes base data from iqm
45 	int         palette_size;	// includes base data from iqm
46 	iqmvertexarray *position;
47 	iqmvertexarray *texcoord;
48 	iqmvertexarray *normal;
49 	iqmvertexarray *bindices;
50 } swiqm_t;
51 
52 typedef struct
53 {
54 	float	u, v;
55 	float	s, t;
56 	float	zi;
57 } emitpoint_t;
58 
59 typedef enum {
60 	part_tex_dot,
61 	part_tex_spark,
62 	part_tex_smoke,
63 } ptextype_t;
64 
65 typedef struct particle_s particle_t;
66 typedef void (*pt_phys_func)(particle_t *);
67 
68 pt_phys_func R_ParticlePhysics (ptype_t type);
69 
70 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
71 struct particle_s
72 {
73 // driver-usable fields
74 	vec3_t		org;
75 	int			color;
76 	float		alpha;
77 	ptextype_t	tex;
78 	float		scale;
79 // drivers never touch the following fields
80 	vec3_t		vel;
81 	ptype_t		type;
82 	float		die;
83 	float		ramp;
84 	pt_phys_func phys;
85 	particle_t *next;
86 };
87 
88 #define PARTICLE_Z_CLIP	8.0
89 
90 typedef struct polyvert_s {
91 	float	u, v, zi, s, t;
92 } polyvert_t;
93 
94 typedef struct polydesc_s {
95 	int			numverts;
96 	float		nearzi;
97 	msurface_t	*pcurrentface;
98 	polyvert_t	*pverts;
99 } polydesc_t;
100 
101 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
102 typedef struct finalvert_s {
103 	int		v[6];		// u, v, s, t, l, 1/z
104 	int		flags;
105 	float	reserved;
106 } finalvert_t;
107 
108 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
109 typedef struct
110 {
111 	void				*pskin;
112 	int					skinwidth;
113 	int					skinheight;
114 	mtriangle_t			*ptriangles;
115 	finalvert_t			*pfinalverts;
116 	int					numtriangles;
117 	int					drawtype;
118 	int					seamfixupX16;
119 } affinetridesc_t;
120 
121 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
122 typedef struct {
123 	float	u, v, zi, color;
124 } screenpart_t;
125 
126 typedef struct
127 {
128 	int			nump;
129 	emitpoint_t	*pverts;	// there's room for an extra element at [nump],
130 							//  if the driver wants to duplicate element [0] at
131 							//  element [nump] to avoid dealing with wrapping
132 	mspriteframe_t	*pspriteframe;
133 	vec3_t			vup, vright, vpn;	// in worldspace
134 	float			nearzi;
135 } spritedesc_t;
136 
137 typedef struct
138 {
139 	int		u, v;
140 	float	zi;
141 	int		color;
142 } zpointdesc_t;
143 
144 extern struct cvar_s	*r_drawflat;
145 extern int		r_framecount;		// sequence # of current frame since Quake
146 									//  started
147 extern qboolean	r_drawpolys;		// 1 if driver wants clipped polygons
148 									//  rather than a span list
149 extern qboolean	r_drawculledpolys;	// 1 if driver wants clipped polygons that
150 									//  have been culled by the edge list
151 extern qboolean	r_worldpolysbacktofront;	// 1 if driver wants polygons
152 											//  delivered back to front rather
153 											//  than front to back
154 extern qboolean	r_recursiveaffinetriangles;	// true if a driver wants to use
155 											//  recursive triangular subdivison
156 											//  and vertex drawing via
157 											//  D_PolysetDrawFinalVerts() past
158 											//  a certain distance (normally
159 											//  used only by the software
160 											//  driver)
161 extern int		r_pixbytes;
162 extern qboolean	r_dowarp;
163 
164 extern affinetridesc_t	r_affinetridesc;
165 extern spritedesc_t		r_spritedesc;
166 extern zpointdesc_t		r_zpointdesc;
167 
168 extern int		d_con_indirect;	// if 0, Quake will draw console directly
169 								//  to vid.buffer; if 1, Quake will
170 								//  draw console via D_DrawRect. Must be
171 								//  defined by driver
172 
173 extern vec3_t	r_pright, r_pup, r_ppn;
174 
175 
176 void D_Aff8Patch (void *pcolormap);
177 void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height);
178 void D_DisableBackBufferAccess (void);
179 void D_EndDirectRect (int x, int y, int width, int height);
180 void D_PolysetDraw (void);
181 void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts);
182 void D_PolysetSetEdgeTable (void);
183 void D_DrawParticle (particle_t *pparticle);
184 void D_DrawPoly (void);
185 void D_DrawSprite (void);
186 void D_DrawSurfaces (void);
187 void D_DrawZPoint (void);
188 void D_EnableBackBufferAccess (void);
189 void D_Init (void);
190 void D_Init_Cvars (void);
191 void D_ViewChanged (void);
192 void D_SetupFrame (void);
193 void D_TurnZOn (void);
194 void D_WarpScreen (void);
195 
196 void D_FillRect (vrect_t *vrect, int color);
197 void D_DrawRect (void);
198 void D_UpdateRects (vrect_t *prect);
199 
200 // currently for internal use only, and should be a do-nothing function in
201 // hardware drivers
202 // FIXME: this should go away
203 void D_PolysetUpdateTables (void);
204 
205 // these are currently for internal use only, and should not be used by drivers
206 extern byte				*r_skysource;
207 
208 // transparency types for D_DrawRect ()
209 #define DR_SOLID		0
210 #define DR_TRANSPARENT	1
211 
212 // !!! must be kept the same as in quakeasm.h !!!
213 #define TRANSPARENT_COLOR	0xFF
214 
215 extern void *acolormap;	// FIXME: should go away
216 
217 //=======================================================================//
218 
219 // callbacks to Quake
220 
221 typedef struct
222 {
223 	byte		*surfdat;	// destination for generated surface
224 	int			rowbytes;	// destination logical width in bytes
225 	msurface_t	*surf;		// description for surface to generate
226 	fixed8_t	lightadj[MAXLIGHTMAPS];
227 							// adjust for lightmap levels for dynamic lighting
228 	texture_t	*texture;	// corrected for animating textures
229 	int			surfmip;	// mipmapped ratio of surface texels / world pixels
230 	int			surfwidth;	// in mipmapped texels
231 	int			surfheight;	// in mipmapped texels
232 } drawsurf_t;
233 
234 extern drawsurf_t	r_drawsurf;
235 
236 void R_DrawSurface (void);
237 void R_GenTile (msurface_t *psurf, void *pdest);
238 
239 // !!! if this is changed, it must be changed in d_iface.h too !!!
240 #define CACHE_SIZE		32		// used to align key data structures
241 
242 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
243 #define TURB_TEX_SIZE	64		// base turbulent texture size
244 
245 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
246 #define	CYCLE			128		// turbulent cycle size
247 
248 #define TILE_SIZE		128		// size of textures generated by R_GenTiledSurf
249 
250 #define SKYSHIFT		7
251 #define	SKYSIZE			(1 << SKYSHIFT)
252 #define SKYMASK			(SKYSIZE - 1)
253 
254 extern float	d_zitable[65536];
255 
256 extern float	r_skyspeed;
257 extern float	r_skytime;
258 
259 extern int		c_surf;
260 extern vrect_t	scr_vrect;
261 
262 extern byte		*r_warpbuffer;
263 
264 #endif // _D_IFACE_H
265