• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright (C) 1996-1997 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 // disable data conversion warnings
21 
22 #ifdef _WIN32
23 #pragma warning(disable : 4244)     // MIPS
24 #pragma warning(disable : 4136)     // X86
25 #pragma warning(disable : 4051)     // ALPHA
26 #endif
27 
28 #ifdef _WIN32
29 #include <windows.h>
30 #endif
31 
32 #ifdef USE_OPENGLES
33 
34 #include <GLES/gl.h>
35 
36 #else
37 
38 #include <GL/gl.h>
39 #include <GL/glu.h>
40 
41 #endif
42 
43 void GL_BeginRendering (int *x, int *y, int *width, int *height);
44 void GL_EndRendering (void);
45 
46 #ifdef USE_OPENGLES
47 
48 #else // full OpenGL
49 
50 // Function prototypes for the Texture Object Extension routines
51 typedef GLboolean (APIENTRY *ARETEXRESFUNCPTR)(GLsizei, const GLuint *,
52                     const GLboolean *);
53 typedef void (APIENTRY *BINDTEXFUNCPTR)(GLenum, GLuint);
54 typedef void (APIENTRY *DELTEXFUNCPTR)(GLsizei, const GLuint *);
55 typedef void (APIENTRY *GENTEXFUNCPTR)(GLsizei, GLuint *);
56 typedef GLboolean (APIENTRY *ISTEXFUNCPTR)(GLuint);
57 typedef void (APIENTRY *PRIORTEXFUNCPTR)(GLsizei, const GLuint *,
58                     const GLclampf *);
59 typedef void (APIENTRY *TEXSUBIMAGEPTR)(int, int, int, int, int, int, int, int, void *);
60 
61 extern	BINDTEXFUNCPTR bindTexFunc;
62 extern	DELTEXFUNCPTR delTexFunc;
63 extern	TEXSUBIMAGEPTR TexSubImage2DFunc;
64 
65 #endif // USE_OPENGLES
66 
67 extern	int texture_extension_number;
68 extern	int		texture_mode;
69 
70 extern	float	gldepthmin, gldepthmax;
71 
72 void GL_Upload32 (unsigned *data, int width, int height,  qboolean mipmap, qboolean alpha);
73 void GL_Upload8 (byte *data, int width, int height,  qboolean mipmap, qboolean alpha);
74 void GL_Upload8_EXT (byte *data, int width, int height,  qboolean mipmap, qboolean alpha);
75 int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha);
76 int GL_FindTexture (char *identifier);
77 
78 void glTexImage2DHelper( GLenum target,
79 	 GLint level,
80 	 GLint internalformat,
81 	 GLsizei width,
82 	 GLsizei height,
83 	 GLint border,
84 	 GLenum format,
85 	 GLenum type,
86 	 const GLvoid *pixels );
87 
88 typedef struct
89 {
90 	float	x, y, z;
91 	float	s, t;
92 	float	r, g, b;
93 } glvert_t;
94 
95 extern glvert_t glv;
96 
97 extern	int glx, gly, glwidth, glheight;
98 
99 #ifdef _WIN32
100 extern	PROC glArrayElementEXT;
101 extern	PROC glColorPointerEXT;
102 extern	PROC glTexturePointerEXT;
103 extern	PROC glVertexPointerEXT;
104 #endif
105 
106 // r_local.h -- private refresh defs
107 
108 #define ALIAS_BASE_SIZE_RATIO		(1.0 / 11.0)
109 					// normalizing factor so player model works out to about
110 					//  1 pixel per triangle
111 #define	MAX_LBM_HEIGHT		480
112 
113 #define TILE_SIZE		128		// size of textures generated by R_GenTiledSurf
114 
115 #define SKYSHIFT		7
116 #define	SKYSIZE			(1 << SKYSHIFT)
117 #define SKYMASK			(SKYSIZE - 1)
118 
119 #define BACKFACE_EPSILON	0.01
120 
121 
122 void R_TimeRefresh_f (void);
123 void R_ReadPointFile_f (void);
124 texture_t *R_TextureAnimation (texture_t *base);
125 
126 typedef struct surfcache_s
127 {
128 	struct surfcache_s	*next;
129 	struct surfcache_s 	**owner;		// NULL is an empty chunk of memory
130 	int					lightadj[MAXLIGHTMAPS]; // checked for strobe flush
131 	int					dlight;
132 	int					size;		// including header
133 	unsigned			width;
134 	unsigned			height;		// DEBUG only needed for debug
135 	float				mipscale;
136 	struct texture_s	*texture;	// checked for animating textures
137 	byte				data[4];	// width*height elements
138 } surfcache_t;
139 
140 
141 typedef struct
142 {
143 	pixel_t		*surfdat;	// destination for generated surface
144 	int			rowbytes;	// destination logical width in bytes
145 	msurface_t	*surf;		// description for surface to generate
146 	fixed8_t	lightadj[MAXLIGHTMAPS];
147 							// adjust for lightmap levels for dynamic lighting
148 	texture_t	*texture;	// corrected for animating textures
149 	int			surfmip;	// mipmapped ratio of surface texels / world pixels
150 	int			surfwidth;	// in mipmapped texels
151 	int			surfheight;	// in mipmapped texels
152 } drawsurf_t;
153 
154 
155 typedef enum {
156 	pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2
157 } ptype_t;
158 
159 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
160 typedef struct particle_s
161 {
162 // driver-usable fields
163 	vec3_t		org;
164 	float		color;
165 // drivers never touch the following fields
166 	struct particle_s	*next;
167 	vec3_t		vel;
168 	float		ramp;
169 	float		die;
170 	ptype_t		type;
171 } particle_t;
172 
173 
174 //====================================================
175 
176 
177 extern	entity_t	r_worldentity;
178 extern	qboolean	r_cache_thrash;		// compatability
179 extern	vec3_t		modelorg, r_entorigin;
180 extern	entity_t	*currententity;
181 extern	int			r_visframecount;	// ??? what difs?
182 extern	int			r_framecount;
183 extern	mplane_t	frustum[4];
184 extern	int		c_brush_polys, c_alias_polys;
185 
186 
187 //
188 // view origin
189 //
190 extern	vec3_t	vup;
191 extern	vec3_t	vpn;
192 extern	vec3_t	vright;
193 extern	vec3_t	r_origin;
194 
195 //
196 // screen size info
197 //
198 extern	refdef_t	r_refdef;
199 extern	mleaf_t		*r_viewleaf, *r_oldviewleaf;
200 extern	texture_t	*r_notexture_mip;
201 extern	int		d_lightstylevalue[256];	// 8.8 fraction of base light value
202 
203 extern	qboolean	envmap;
204 extern	int	currenttexture;
205 extern	int	cnttextures[2];
206 extern	int	particletexture;
207 extern	int	netgraphtexture;	// netgraph texture
208 extern	int	playertextures;
209 
210 extern	int	skytexturenum;		// index in cl.loadmodel, not gl texture object
211 
212 extern	cvar_t	r_norefresh;
213 extern	cvar_t	r_drawentities;
214 extern	cvar_t	r_drawworld;
215 extern	cvar_t	r_drawviewmodel;
216 extern	cvar_t	r_speeds;
217 extern	cvar_t	r_waterwarp;
218 extern	cvar_t	r_fullbright;
219 extern	cvar_t	r_lightmap;
220 extern	cvar_t	r_shadows;
221 extern	cvar_t	r_mirroralpha;
222 extern	cvar_t	r_wateralpha;
223 extern	cvar_t	r_dynamic;
224 extern	cvar_t	r_novis;
225 extern	cvar_t	r_netgraph;
226 
227 extern	cvar_t	gl_clear;
228 extern	cvar_t	gl_cull;
229 extern	cvar_t	gl_poly;
230 extern	cvar_t	gl_texsort;
231 extern	cvar_t	gl_smoothmodels;
232 extern	cvar_t	gl_affinemodels;
233 extern	cvar_t	gl_polyblend;
234 extern	cvar_t	gl_keeptjunctions;
235 extern	cvar_t	gl_reporttjunctions;
236 extern	cvar_t	gl_flashblend;
237 extern	cvar_t	gl_nocolors;
238 extern	cvar_t	gl_finish;
239 
240 extern	int		gl_lightmap_format;
241 extern	int		gl_solid_format;
242 extern	int		gl_alpha_format;
243 
244 extern	cvar_t	gl_max_size;
245 extern	cvar_t	gl_playermip;
246 
247 extern	int			mirrortexturenum;	// quake texturenum, not gltexturenum
248 extern	qboolean	mirror;
249 extern	mplane_t	*mirror_plane;
250 
251 extern	float	r_world_matrix[16];
252 
253 extern	const char *gl_vendor;
254 extern	const char *gl_renderer;
255 extern	const char *gl_version;
256 extern	const char *gl_extensions;
257 
258 void R_TranslatePlayerSkin (int playernum);
259 void GL_Bind (int texnum);
260 
261 // Multitexture
262 #define    TEXTURE0_SGIS				0x835E
263 #define    TEXTURE1_SGIS				0x835F
264 
265 #ifdef _WIN32
266 typedef void (APIENTRY *lpMTexFUNC) (GLenum, GLfloat, GLfloat);
267 typedef void (APIENTRY *lpSelTexFUNC) (GLenum);
268 extern lpMTexFUNC qglMTexCoord2fSGIS;
269 extern lpSelTexFUNC qglSelectTextureSGIS;
270 #endif
271 
272 extern qboolean gl_mtexable;
273 
274 void GL_DisableMultitexture(void);
275 void GL_EnableMultitexture(void);
276 
277 //
278 // gl_warp.c
279 //
280 void GL_SubdivideSurface (msurface_t *fa);
281 void EmitBothSkyLayers (msurface_t *fa);
282 void EmitWaterPolys (msurface_t *fa);
283 void EmitSkyPolys (msurface_t *fa);
284 void R_DrawSkyChain (msurface_t *s);
285 
286 //
287 // gl_draw.c
288 //
289 int GL_LoadPicTexture (qpic_t *pic);
290 void GL_Set2D (void);
291 
292 //
293 // gl_rmain.c
294 //
295 qboolean R_CullBox (vec3_t mins, vec3_t maxs);
296 void R_RotateForEntity (entity_t *e);
297 
298 //
299 // gl_rlight.c
300 //
301 void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
302 void R_AnimateLight (void);
303 void R_RenderDlights (void);
304 int R_LightPoint (vec3_t p);
305 
306 //
307 // gl_refrag.c
308 //
309 void R_StoreEfrags (efrag_t **ppefrag);
310 
311 //
312 // gl_mesh.c
313 //
314 void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr);
315 
316 //
317 // gl_rsurf.c
318 //
319 void R_DrawBrushModel (entity_t *e);
320 void R_DrawWorld (void);
321 void GL_BuildLightmaps (void);
322 
323 //
324 // gl_ngraph.c
325 //
326 void R_NetGraph (void);
327 
328