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
23 //#pragma warning(disable : 4244) // MIPS
24 //#pragma warning(disable : 4136) // X86
25 //#pragma warning(disable : 4051) // ALPHA
26 #pragma warning(disable : 4244) // LordHavoc: MSVC++ 4 x86, double/float
27 #pragma warning(disable : 4305) // LordHavoc: MSVC++ 6 x86, double/float
28 #pragma warning(disable : 4018) // LordHavoc: MSVC++ 4 x86, signed/unsigned mismatch
33 #define strcasecmp stricmp
34 #define strncasecmp strnicmp
40 void GL_BeginRendering (int *x, int *y, int *width, int *height);
41 void GL_EndRendering (void);
43 extern int texture_extension_number;
45 extern float gldepthmin, gldepthmax;
47 void GL_Upload32 (void *data, int width, int height, qboolean mipmap, qboolean alpha);
48 void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
49 int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel);
50 int GL_FindTexture (char *identifier);
61 extern int glx, gly, glwidth, glheight;
63 // r_local.h -- private refresh defs
65 #define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
66 // normalizing factor so player model works out to about
67 // 1 pixel per triangle
68 #define MAX_LBM_HEIGHT 480
70 #define BACKFACE_EPSILON 0.01
73 void R_TimeRefresh_f (void);
74 void R_ReadPointFile_f (void);
76 //====================================================
79 extern entity_t r_worldentity;
80 extern qboolean r_cache_thrash; // compatability
81 extern vec3_t modelorg, r_entorigin;
82 extern entity_t *currententity;
83 extern int r_visframecount; // ??? what difs?
84 extern int r_framecount;
85 extern mplane_t frustum[4];
86 extern int c_brush_polys, c_alias_polys, c_light_polys, c_nodes, c_leafs;
95 extern vec3_t r_origin;
100 extern refdef_t r_refdef;
101 extern mleaf_t *r_viewleaf, *r_oldviewleaf;
102 extern texture_t *r_notexture_mip;
103 extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
105 extern qboolean envmap;
106 extern int cnttextures[2];
107 // LordHavoc: moved all code relating to particles into r_part.c
108 //extern int particletexture;
109 extern int playertextures;
111 extern int skytexturenum; // index in cl.loadmodel, not gl texture object
113 //extern cvar_t r_norefresh;
114 extern cvar_t r_drawentities;
115 //extern cvar_t r_drawworld;
116 extern cvar_t r_drawviewmodel;
117 extern cvar_t r_speeds;
118 //extern cvar_t r_waterwarp;
119 extern cvar_t r_fullbright;
120 //extern cvar_t r_lightmap;
121 extern cvar_t r_shadows;
122 extern cvar_t r_wateralpha;
123 extern cvar_t r_dynamic;
124 extern cvar_t r_novis;
125 extern cvar_t r_waterripple;
127 //extern cvar_t gl_cull;
128 //extern cvar_t gl_poly;
129 //extern cvar_t gl_smoothmodels;
130 //extern cvar_t gl_affinemodels;
131 //extern cvar_t gl_polyblend;
132 //extern cvar_t gl_keeptjunctions;
133 //extern cvar_t gl_reporttjunctions;
134 //extern cvar_t gl_nocolors;
135 //extern cvar_t gl_doubleeyes;
137 extern cvar_t gl_max_size;
138 extern cvar_t gl_playermip;
140 extern float r_world_matrix[16];
142 extern const char *gl_vendor;
143 extern const char *gl_renderer;
144 extern const char *gl_version;
145 extern const char *gl_extensions;
147 void R_TranslatePlayerSkin (int playernum);
150 #define TEXTURE0_SGIS 0x835E
151 #define TEXTURE1_SGIS 0x835F
154 #define APIENTRY /* */
157 extern qboolean gl_mtexable;
159 // LordHavoc: ARB multitexure support
160 extern int gl_mtex_enum;
161 // Micro$oft dropped GL support beyond 1.1, so...
164 //#define GL_POLYGON_OFFSET_POINT 0x2A01
165 //#define GL_POLYGON_OFFSET_LINE 0x2A02
166 //#define GL_POLYGON_OFFSET_FILL 0x8037
168 #define GL_ACTIVE_TEXTURE_ARB 0x84E0
169 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
170 #define GL_MAX_TEXTURES_UNITS_ARB 0x84E2
171 #define GL_TEXTURE0_ARB 0x84C0
172 #define GL_TEXTURE1_ARB 0x84C1
173 #define GL_TEXTURE2_ARB 0x84C2
174 #define GL_TEXTURE3_ARB 0x84C3
175 // LordHavoc: ARB supports 32+ texture units, but hey I only use 2 anyway...
177 // LordHavoc: vertex array defines
178 #define GL_VERTEX_ARRAY 0x8074
179 //#define GL_NORMAL_ARRAY 0x8075
180 #define GL_COLOR_ARRAY 0x8076
181 //#define GL_INDEX_ARRAY 0x8077
182 #define GL_TEXTURE_COORD_ARRAY 0x8078
183 //#define GL_EDGE_FLAG_ARRAY 0x8079
185 #define GL_V2F 0x2A20
186 #define GL_V3F 0x2A21
187 #define GL_C4UB_V2F 0x2A22
188 #define GL_C4UB_V3F 0x2A23
189 #define GL_C3F_V3F 0x2A24
190 #define GL_N3F_V3F 0x2A25
191 #define GL_C4F_N3F_V3F 0x2A26
192 #define GL_T2F_V3F 0x2A27
193 #define GL_T4F_V4F 0x2A28
194 #define GL_T2F_C4UB_V3F 0x2A29
195 #define GL_T2F_C3F_V3F 0x2A2A
196 #define GL_T2F_N3F_V3F 0x2A2B
197 #define GL_T2F_C4F_N3F_V3F 0x2A2C
198 #define GL_T4F_C4F_N3F_V4F 0x2A2D
201 //extern void (APIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
202 extern void (APIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
203 //extern void (APIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
204 extern void (APIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
205 //extern void (APIENTRY *qglIndexPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
206 extern void (APIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
207 //extern void (APIENTRY *qglEdgeFlagPointer)(GLsizei stride, const GLvoid *ptr);
208 //extern void (APIENTRY *qglGetPointerv)(GLenum pname, void **params);
209 extern void (APIENTRY *qglArrayElement)(GLint i);
210 //extern void (APIENTRY *qglDrawArrays)(GLenum mode, GLint first, GLsizei count);
211 extern void (APIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
212 //extern void (APIENTRY *qglInterleavedArrays)(GLenum format, GLsizei stride, const GLvoid *pointer);
214 extern void (APIENTRY *qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
215 extern void (APIENTRY *qglSelectTexture) (GLenum);
216 extern void (APIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
220 //#define qglPolygonOffset glPolygonOffset
221 #define qglVertexPointer glVertexPointer
222 //#define qglNormalPointer glNormalPointer
223 #define qglColorPointer glColorPointer
224 //#define qglIndexPointer glIndexPointer
225 #define qglTexCoordPointer glTexCoordPointer
226 //#define qglEdgeFlagPointer glEdgeFlagPointer
227 //#define qglGetPointerv glGetPointerv
228 #define qglArrayElement glArrayElement
229 //#define qglDrawArrays glDrawArrays
230 #define qglDrawElements glDrawElements
231 //#define qglInterleavedArrays glInterleavedArrays
233 extern void (*qglMTexCoord2f) (GLenum, GLfloat, GLfloat);
234 extern void (*qglSelectTexture) (GLenum);
236 extern void (*glColorTableEXT)(int, int, int, int, int, const void*);
241 // LordHavoc: vertex transform
242 #include "transform.h"
244 // LordHavoc: transparent polygon system
247 #define gl_solid_format 3
248 #define gl_alpha_format 4
252 // LordHavoc: was a major time waster
253 #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)
254 #define R_NotCulledBox(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)
256 extern qboolean fogenabled;
257 extern vec3_t fogcolor;
258 extern vec_t fogdensity;
259 //#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]))))
260 #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])))))
261 #define calcfogbyte(v) ((byte) (bound(0, ((int) ((float) (calcfog((v)) * 255.0f))), 255)))