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 //
22 // ref_public.h
23 //
24 
25 #ifndef __REF_H
26 #define __REF_H
27 
28 #define	MAX_DLIGHTS		32
29 #define	MAX_ENTITIES	128
30 #define	MAX_PARTICLES	4096
31 #define	MAX_LIGHTSTYLES	256
32 
33 #define POWERSUIT_SCALE		4.0F
34 
35 #define SHELL_RED_COLOR		0xF2
36 #define SHELL_GREEN_COLOR	0xD0
37 #define SHELL_BLUE_COLOR	0xF3
38 
39 #define SHELL_RG_COLOR		0xDC
40 //#define SHELL_RB_COLOR		0x86
41 #define SHELL_RB_COLOR		0x68
42 #define SHELL_BG_COLOR		0x78
43 
44 //ROGUE
45 #define SHELL_DOUBLE_COLOR	0xDF // 223
46 #define	SHELL_HALF_DAM_COLOR	0x90
47 #define SHELL_CYAN_COLOR	0x72
48 //ROGUE
49 
50 #define SHELL_WHITE_COLOR	0xD7
51 
52 #define RF_LEFTHAND			0x80000000
53 
54 typedef struct entity_s {
55 	qhandle_t			model;			// opaque type outside refresh
56 	vec3_t				angles;
57 
58 	/*
59 	** most recent data
60 	*/
61 	vec3_t				origin;		// also used as RF_BEAM's "from"
62 	int					frame;			// also used as RF_BEAM's diameter
63 
64 	/*
65 	** previous data for lerping
66 	*/
67 	vec3_t				oldorigin;	// also used as RF_BEAM's "to"
68 	int					oldframe;
69 
70 	/*
71 	** misc
72 	*/
73 	float	backlerp;				// 0.0 = current, 1.0 = old
74 	int		skinnum;				// also used as RF_BEAM's palette index
75 
76 	int		lightstyle;				// for flashing entities
77 	float	alpha;					// ignore if RF_TRANSLUCENT isn't set
78 
79 	qhandle_t	skin;			// NULL for inline skin
80 	int			flags;
81 } entity_t;
82 
83 #define ENTITY_FLAGS  68
84 
85 typedef struct dlight_s {
86 	int		index;
87 	vec3_t	origin;
88 	vec3_t	transformed;
89 	vec3_t	color;
90 	float	intensity;
91 } dlight_t;
92 
93 typedef struct particle_s {
94 	vec3_t	origin;
95 	int		color;
96 	float	alpha;
97 	color_t		rgb;
98 } particle_t;
99 
100 typedef struct lightstyle_s {
101 	float			white;			// highest of RGB
102 	vec3_t			rgb;			// 0.0 - 2.0
103 } lightstyle_t;
104 
105 typedef struct refdef_s {
106 	int			x, y, width, height;// in virtual screen coordinates
107 	float		fov_x, fov_y;
108 	vec3_t		vieworg;
109 	vec3_t		viewangles;
110 	vec4_t		blend;			// rgba 0-1 full screen blend
111 	float		time;				// time is uesed to auto animate
112 	int			rdflags;			// RDF_UNDERWATER, etc
113 
114 	byte		*areabits;			// if not NULL, only areas with set bits will be drawn
115 
116 	lightstyle_t	*lightstyles;	// [MAX_LIGHTSTYLES]
117 
118 	int			num_entities;
119 	entity_t	*entities;
120 
121 	int			num_dlights;
122 	dlight_t	*dlights;
123 
124 	int			num_particles;
125 	particle_t	*particles;
126 } refdef_t;
127 
128 typedef enum glHardware_e {
129 	GL_RENDERER_OTHER,
130 	GL_RENDERER_SOFTWARE,
131 	GL_RENDERER_MCD,
132 	GL_RENDERER_VOODOO,
133 	GL_RENDERER_VOODOO_RUSH,
134 	GL_RENDERER_POWERVR,
135 	GL_RENDERER_GLINT,
136 	GL_RENDERER_PERMEDIA2,
137 	GL_RENDERER_INTERGRAPH,
138 	GL_RENDERER_RENDITION,
139     GL_RENDERER_MESADRI
140 } glHardware_t;
141 
142 typedef struct glconfig_s {
143 	glHardware_t	renderer;
144 	const char *rendererString;
145 	const char *vendorString;
146 	const char *versionString;
147 	const char *extensionsString;
148 
149 	int		vidWidth;
150 	int		vidHeight;
151 
152 	qboolean	isFullscreen;
153 	qboolean	allowCDS;
154 	float		maxAnisotropy;
155 } glconfig_t;
156 
157 #define	DRAW_COLOR_CLEAR	0
158 #define	DRAW_COLOR_RGB		0x00000001
159 #define	DRAW_COLOR_ALPHA	0x00000002
160 #define	DRAW_COLOR_RGBA	    0x00000003
161 #define	DRAW_COLOR_INDEXED	0x00000004
162 #define	DRAW_COLOR_MASK		0x00000007
163 
164 
165 #define	DRAW_CLIP_DISABLED	0
166 #define DRAW_CLIP_LEFT		0x00000004
167 #define DRAW_CLIP_RIGHT		0x00000008
168 #define DRAW_CLIP_TOP		0x00000010
169 #define DRAW_CLIP_BOTTOM	0x00000020
170 #define DRAW_CLIP_MASK		0x0000003C
171 
172 typedef struct {
173 	int left, right, top, bottom;
174 } clipRect_t;
175 
176 //
177 // these are the functions exported by the refresh module
178 //
179 typedef struct refAPI_s {
180 	// called when the library is loaded
181 	qboolean	(*Init)( qboolean total );
182 
183 	// called before the library is unloaded
184 	void	(*Shutdown)( qboolean total );
185 
186 	// All data that will be used in a level should be
187 	// registered before rendering any frames to prevent disk hits,
188 	// but they can still be registered at a later time
189 	// if necessary.
190 	//
191 	// EndRegistration will free any remaining data that wasn't registered.
192 	// Any model_s or skin_s pointers from before the BeginRegistration
193 	// are no longer valid after EndRegistration.
194 	//
195 	// Skins and images need to be differentiated, because skins
196 	// are flood filled to eliminate mip map edge errors, and pics have
197 	// an implicit "pics/" prepended to the name. (a pic name that starts with a
198 	// slash will not use the "pics/" prefix or the ".pcx" postfix)
199 	void	(*BeginRegistration)( const char *map );
200 	qhandle_t (*RegisterModel)( const char *name );
201 	qhandle_t (*RegisterSkin)( const char *name );
202 	qhandle_t (*RegisterPic)( const char *name );
203 	qhandle_t (*RegisterFont)( const char *name );
204 	void	(*SetSky)( const char *name, float rotate, vec3_t axis );
205 	void	(*EndRegistration)( void );
206 	void	(*GetModelSize)( qhandle_t hModel, vec3_t mins, vec3_t maxs );
207 
208 	void	(*RenderFrame)( refdef_t *fd );
209 	void	(*LightPoint)( vec3_t origin, vec3_t light );
210 
211 	void	(*SetColor)( uint32 flags, const color_t color );
212 	void	(*SetClipRect)( uint32 flags, const clipRect_t *clip );
213 	void	(*SetScale)( float *scale );
214     void    (*DrawChar)( int x, int y, uint32 flags, int ch, qhandle_t hFont );
215 	void	(*DrawString)( int x, int y, uint32 flags, int maxChars,
216             const char *string, qhandle_t hFont );
217     // will return 0 0 if not found
218 	void	(*DrawGetPicSize)( int *w, int *h, qhandle_t hPic );
219 	void	(*DrawGetFontSize)( int *w, int *h, qhandle_t hFont );
220 	void	(*DrawPic)( int x, int y, qhandle_t hPic );
221 	void	(*DrawStretchPic)( int x, int y, int w, int h, qhandle_t hPic );
222 	void	(*DrawStretchPicST)( int x, int y, int w, int h,
223             float s1, float t1, float s2, float t2, qhandle_t hPic );
224 	void	(*DrawTileClear)( int x, int y, int w, int h, qhandle_t hPic );
225 	void	(*DrawFill)( int x, int y, int w, int h, int c );
226 	void	(*DrawFillEx)( int x, int y, int w, int h, const color_t color );
227 
228 	// Draw images for cinematic rendering (which can have a different palette).
229 	void	(*DrawStretchRaw)( int x, int y, int w, int h, int cols, int rows, const byte *data );
230 
231 	/*
232 	** video mode and refresh state management entry points
233 	*/
234 	void	(*CinematicSetPalette)( const byte *palette );	// NULL = game palette
235 	void	(*BeginFrame)( float camera_separation );
236 	void	(*EndFrame)( void );
237 
238 	void	(*GetConfig)( glconfig_t *dest );
239 } refAPI_t;
240 
241 extern refAPI_t		ref;
242 
243 #endif // __REF_H
244