2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
20 // disable data conversion warnings
22 #pragma warning(disable : 4244) // MIPS
23 #pragma warning(disable : 4136) // X86
24 #pragma warning(disable : 4051) // ALPHA
25 #pragma warning(disable : 4305) // LordHavoc: MSVC++ 6 x86, double/float
26 #pragma warning(disable : 4018) // LordHavoc: MSVC++ 4, signed/unsigned mismatch
35 void GL_BeginRendering (int *x, int *y, int *width, int *height);
36 void GL_EndRendering (void);
40 // Function prototypes for the Texture Object Extension routines
41 typedef GLboolean (APIENTRY *ARETEXRESFUNCPTR)(GLsizei, const GLuint *,
43 typedef void (APIENTRY *BINDTEXFUNCPTR)(GLenum, GLuint);
44 typedef void (APIENTRY *DELTEXFUNCPTR)(GLsizei, const GLuint *);
45 typedef void (APIENTRY *GENTEXFUNCPTR)(GLsizei, GLuint *);
46 typedef GLboolean (APIENTRY *ISTEXFUNCPTR)(GLuint);
47 typedef void (APIENTRY *PRIORTEXFUNCPTR)(GLsizei, const GLuint *,
49 typedef void (APIENTRY *TEXSUBIMAGEPTR)(int, int, int, int, int, int, int, int, void *);
51 extern BINDTEXFUNCPTR bindTexFunc;
52 extern DELTEXFUNCPTR delTexFunc;
53 extern TEXSUBIMAGEPTR TexSubImage2DFunc;
56 extern int texture_extension_number;
58 extern float gldepthmin, gldepthmax;
60 void GL_Upload32 (void *data, int width, int height, qboolean mipmap, qboolean alpha);
61 void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
62 int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel);
63 int GL_FindTexture (char *identifier);
74 extern int glx, gly, glwidth, glheight;
77 extern PROC glArrayElementEXT;
78 extern PROC glColorPointerEXT;
79 extern PROC glTexturePointerEXT;
80 extern PROC glVertexPointerEXT;
83 // r_local.h -- private refresh defs
85 #define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
86 // normalizing factor so player model works out to about
87 // 1 pixel per triangle
88 #define MAX_LBM_HEIGHT 480
90 #define BACKFACE_EPSILON 0.01
93 void R_TimeRefresh_f (void);
94 void R_ReadPointFile_f (void);
96 typedef struct surfcache_s
98 struct surfcache_s *next;
99 struct surfcache_s **owner; // NULL is an empty chunk of memory
100 int lightadj[MAXLIGHTMAPS]; // checked for strobe flush
102 int size; // including header
104 unsigned height; // DEBUG only needed for debug
106 struct texture_s *texture; // checked for animating textures
107 byte data[4]; // width*height elements
113 pixel_t *surfdat; // destination for generated surface
114 msurface_t *surf; // description for surface to generate
115 fixed8_t lightadj[MAXLIGHTMAPS];
116 // adjust for lightmap levels for dynamic lighting
117 texture_t *texture; // corrected for animating textures
118 int surfmip; // mipmapped ratio of surface texels / world pixels
119 int surfwidth; // in mipmapped texels
120 int surfheight; // in mipmapped texels
123 // LordHavoc: added dust, smoke, snow, bloodcloud, and many others
125 pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2, pt_dust, pt_smoke, pt_snow, pt_bulletpuff, pt_bloodcloud, pt_fadespark, pt_fadespark2, pt_fallfadespark, pt_fallfadespark2, pt_bubble
128 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
129 typedef struct particle_s
131 // driver-usable fields
134 // drivers never touch the following fields
135 struct particle_s *next;
140 // LordHavoc: added for improved particle effects
143 short contents; // if non-zero, particles will die outside of this content type
144 float alpha; // 0-255
145 float time2; // used for various things (snow fluttering, for example)
146 vec3_t vel2; // used for snow fluttering (base velocity, wind for instance)
150 //====================================================
153 extern entity_t r_worldentity;
154 extern qboolean r_cache_thrash; // compatability
155 extern vec3_t modelorg, r_entorigin;
156 extern entity_t *currententity;
157 extern int r_visframecount; // ??? what difs?
158 extern int r_framecount;
159 extern mplane_t frustum[4];
160 extern int c_brush_polys, c_alias_polys;
168 extern vec3_t vright;
169 extern vec3_t r_origin;
174 extern refdef_t r_refdef;
175 extern mleaf_t *r_viewleaf, *r_oldviewleaf;
176 extern texture_t *r_notexture_mip;
177 extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
179 extern qboolean envmap;
180 extern int cnttextures[2];
181 // LordHavoc: moved all code relating to particles into r_part.c
182 //extern int particletexture;
183 extern int playertextures;
185 extern int skytexturenum; // index in cl.loadmodel, not gl texture object
187 //extern cvar_t r_norefresh;
188 extern cvar_t r_drawentities;
189 //extern cvar_t r_drawworld;
190 extern cvar_t r_drawviewmodel;
191 extern cvar_t r_speeds;
192 //extern cvar_t r_waterwarp;
193 extern cvar_t r_fullbright;
194 //extern cvar_t r_lightmap;
195 //extern cvar_t r_shadows;
196 extern cvar_t r_wateralpha;
197 //extern cvar_t r_dynamic;
198 extern cvar_t r_novis;
199 extern cvar_t r_waterripple;
201 //extern cvar_t gl_cull;
202 //extern cvar_t gl_poly;
203 //extern cvar_t gl_smoothmodels;
204 //extern cvar_t gl_affinemodels;
205 //extern cvar_t gl_polyblend;
206 //extern cvar_t gl_keeptjunctions;
207 //extern cvar_t gl_reporttjunctions;
208 //extern cvar_t gl_flashblend;
209 //extern cvar_t gl_nocolors;
210 //extern cvar_t gl_doubleeyes;
212 extern cvar_t gl_max_size;
213 extern cvar_t gl_playermip;
215 extern float r_world_matrix[16];
217 extern const char *gl_vendor;
218 extern const char *gl_renderer;
219 extern const char *gl_version;
220 extern const char *gl_extensions;
222 void R_TranslatePlayerSkin (int playernum);
225 #define TEXTURE0_SGIS 0x835E
226 #define TEXTURE1_SGIS 0x835F
229 #define APIENTRY /* */
232 extern qboolean gl_mtexable;
234 // LordHavoc: ARB multitexure support
235 extern int gl_mtex_enum;
236 // Micro$oft dropped GL support beyond 1.1, so...
239 //#define GL_POLYGON_OFFSET_POINT 0x2A01
240 //#define GL_POLYGON_OFFSET_LINE 0x2A02
241 //#define GL_POLYGON_OFFSET_FILL 0x8037
243 #define GL_ACTIVE_TEXTURE_ARB 0x84E0
244 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
245 #define GL_MAX_TEXTURES_UNITS_ARB 0x84E2
246 #define GL_TEXTURE0_ARB 0x84C0
247 #define GL_TEXTURE1_ARB 0x84C1
248 #define GL_TEXTURE2_ARB 0x84C2
249 #define GL_TEXTURE3_ARB 0x84C3
250 // LordHavoc: ARB supports 32+ texture units, but hey I only use 2 anyway...
252 // LordHavoc: vertex array defines
253 #define GL_VERTEX_ARRAY 0x8074
254 //#define GL_NORMAL_ARRAY 0x8075
255 #define GL_COLOR_ARRAY 0x8076
256 //#define GL_INDEX_ARRAY 0x8077
257 #define GL_TEXTURE_COORD_ARRAY 0x8078
258 //#define GL_EDGE_FLAG_ARRAY 0x8079
260 #define GL_V2F 0x2A20
261 #define GL_V3F 0x2A21
262 #define GL_C4UB_V2F 0x2A22
263 #define GL_C4UB_V3F 0x2A23
264 #define GL_C3F_V3F 0x2A24
265 #define GL_N3F_V3F 0x2A25
266 #define GL_C4F_N3F_V3F 0x2A26
267 #define GL_T2F_V3F 0x2A27
268 #define GL_T4F_V4F 0x2A28
269 #define GL_T2F_C4UB_V3F 0x2A29
270 #define GL_T2F_C3F_V3F 0x2A2A
271 #define GL_T2F_N3F_V3F 0x2A2B
272 #define GL_T2F_C4F_N3F_V3F 0x2A2C
273 #define GL_T4F_C4F_N3F_V4F 0x2A2D
276 //extern void (APIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
277 extern void (APIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
278 //extern void (APIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
279 extern void (APIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
280 //extern void (APIENTRY *qglIndexPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
281 extern void (APIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
282 //extern void (APIENTRY *qglEdgeFlagPointer)(GLsizei stride, const GLvoid *ptr);
283 //extern void (APIENTRY *qglGetPointerv)(GLenum pname, void **params);
284 extern void (APIENTRY *qglArrayElement)(GLint i);
285 //extern void (APIENTRY *qglDrawArrays)(GLenum mode, GLint first, GLsizei count);
286 extern void (APIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
287 //extern void (APIENTRY *qglInterleavedArrays)(GLenum format, GLsizei stride, const GLvoid *pointer);
291 //#define qglPolygonOffset glPolygonOffset
292 #define qglVertexPointer glVertexPointer
293 //#define qglNormalPointer glNormalPointer
294 #define qglColorPointer glColorPointer
295 //#define qglIndexPointer glIndexPointer
296 #define qglTexCoordPointer glTexCoordPointer
297 //#define qglEdgeFlagPointer glEdgeFlagPointer
298 //#define qglGetPointerv glGetPointerv
299 #define qglArrayElement glArrayElement
300 //#define qglDrawArrays glDrawArrays
301 #define qglDrawElements glDrawElements
302 //#define qglInterleavedArrays glInterleavedArrays
306 extern void (APIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
307 extern void (APIENTRY *qglSelectTexture) (GLenum);
308 extern void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
310 // LordHavoc: vertex transform
311 #include "transform.h"
313 // LordHavoc: transparent polygon system
316 #define gl_solid_format 3
317 #define gl_alpha_format 4
321 // LordHavoc: was a major time waster
322 #define R_CullBox(mins,maxs) (frustum[0].BoxOnPlaneSideFunc(mins, maxs, &frustum[0]) == 2 || frustum[1].BoxOnPlaneSideFunc(mins, maxs, &frustum[1]) == 2 || frustum[2].BoxOnPlaneSideFunc(mins, maxs, &frustum[2]) == 2 || frustum[3].BoxOnPlaneSideFunc(mins, maxs, &frustum[3]) == 2)
324 extern qboolean fogenabled;
325 extern vec3_t fogcolor;
326 extern vec_t fogdensity;
327 //#define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_refdef.vieworg[0]) * vpn[0] + ((v)[1] - r_refdef.vieworg[1]) * vpn[1] + ((v)[2] - r_refdef.vieworg[2]) * vpn[2])*(((v)[0] - r_refdef.vieworg[0]) * vpn[0] + ((v)[1] - r_refdef.vieworg[1]) * vpn[1] + ((v)[2] - r_refdef.vieworg[2]) * vpn[2]))))
328 #define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_refdef.vieworg[0])*((v)[0] - r_refdef.vieworg[0])+((v)[1] - r_refdef.vieworg[1])*((v)[1] - r_refdef.vieworg[1])+((v)[2] - r_refdef.vieworg[2])*((v)[2] - r_refdef.vieworg[2])))))
329 #define calcfogbyte(v) ((byte) (bound(0, ((int) ((float) (calcfog((v)) * 255.0f))), 255)))