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 // r_local.h
22 // Refresh only header file
23 //
24 
25 #ifdef DEDICATED_ONLY
26 # error You should not be including this file in a dedicated server build
27 #endif // DEDICATED_ONLY
28 
29 #define SHADOW_VOLUMES	2
30 #define SHADOW_ALPHA	0.5f
31 
32 #ifdef WIN32
33 # include <windows.h>
34 #endif
35 
36 #include <GL/gl.h>
37 #include <math.h>
38 
39 #include "r_public.h"
40 #include "r_typedefs.h"
41 #include "rb_qgl.h"
42 #include "rf_image.h"
43 #include "rf_program.h"
44 #include "rf_shader.h"
45 #include "rf_public.h"
46 #include "rb_public.h"
47 #include "rf_model.h"
48 
49 /*
50 =============================================================================
51 
52 	EXTENSIONS
53 
54 =============================================================================
55 */
56 
57 // GL_ARB_vertex_program
58 #define GL_COLOR_SUM_ARB                  0x8458
59 #define GL_VERTEX_PROGRAM_ARB             0x8620
60 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
61 #define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB   0x8623
62 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
63 #define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB   0x8625
64 #define GL_CURRENT_VERTEX_ATTRIB_ARB      0x8626
65 #define GL_PROGRAM_LENGTH_ARB             0x8627
66 #define GL_PROGRAM_STRING_ARB             0x8628
67 #define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
68 #define GL_MAX_PROGRAM_MATRICES_ARB       0x862F
69 #define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
70 #define GL_CURRENT_MATRIX_ARB             0x8641
71 #define GL_VERTEX_PROGRAM_POINT_SIZE_ARB  0x8642
72 #define GL_VERTEX_PROGRAM_TWO_SIDE_ARB    0x8643
73 #define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
74 #define GL_PROGRAM_ERROR_POSITION_ARB     0x864B
75 #define GL_PROGRAM_BINDING_ARB            0x8677
76 #define GL_MAX_VERTEX_ATTRIBS_ARB         0x8869
77 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
78 #define GL_PROGRAM_ERROR_STRING_ARB       0x8874
79 #define GL_PROGRAM_FORMAT_ASCII_ARB       0x8875
80 #define GL_PROGRAM_FORMAT_ARB             0x8876
81 #define GL_PROGRAM_INSTRUCTIONS_ARB       0x88A0
82 #define GL_MAX_PROGRAM_INSTRUCTIONS_ARB   0x88A1
83 #define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
84 #define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
85 #define GL_PROGRAM_TEMPORARIES_ARB        0x88A4
86 #define GL_MAX_PROGRAM_TEMPORARIES_ARB    0x88A5
87 #define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
88 #define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
89 #define GL_PROGRAM_PARAMETERS_ARB         0x88A8
90 #define GL_MAX_PROGRAM_PARAMETERS_ARB     0x88A9
91 #define GL_PROGRAM_NATIVE_PARAMETERS_ARB  0x88AA
92 #define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
93 #define GL_PROGRAM_ATTRIBS_ARB            0x88AC
94 #define GL_MAX_PROGRAM_ATTRIBS_ARB        0x88AD
95 #define GL_PROGRAM_NATIVE_ATTRIBS_ARB     0x88AE
96 #define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
97 #define GL_PROGRAM_ADDRESS_REGISTERS_ARB  0x88B0
98 #define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
99 #define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
100 #define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
101 #define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
102 #define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
103 #define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
104 #define GL_TRANSPOSE_CURRENT_MATRIX_ARB   0x88B7
105 #define GL_MATRIX0_ARB                    0x88C0
106 #define GL_MATRIX1_ARB                    0x88C1
107 #define GL_MATRIX2_ARB                    0x88C2
108 #define GL_MATRIX3_ARB                    0x88C3
109 #define GL_MATRIX4_ARB                    0x88C4
110 #define GL_MATRIX5_ARB                    0x88C5
111 #define GL_MATRIX6_ARB                    0x88C6
112 #define GL_MATRIX7_ARB                    0x88C7
113 #define GL_MATRIX8_ARB                    0x88C8
114 #define GL_MATRIX9_ARB                    0x88C9
115 #define GL_MATRIX10_ARB                   0x88CA
116 #define GL_MATRIX11_ARB                   0x88CB
117 #define GL_MATRIX12_ARB                   0x88CC
118 #define GL_MATRIX13_ARB                   0x88CD
119 #define GL_MATRIX14_ARB                   0x88CE
120 #define GL_MATRIX15_ARB                   0x88CF
121 #define GL_MATRIX16_ARB                   0x88D0
122 #define GL_MATRIX17_ARB                   0x88D1
123 #define GL_MATRIX18_ARB                   0x88D2
124 #define GL_MATRIX19_ARB                   0x88D3
125 #define GL_MATRIX20_ARB                   0x88D4
126 #define GL_MATRIX21_ARB                   0x88D5
127 #define GL_MATRIX22_ARB                   0x88D6
128 #define GL_MATRIX23_ARB                   0x88D7
129 #define GL_MATRIX24_ARB                   0x88D8
130 #define GL_MATRIX25_ARB                   0x88D9
131 #define GL_MATRIX26_ARB                   0x88DA
132 #define GL_MATRIX27_ARB                   0x88DB
133 #define GL_MATRIX28_ARB                   0x88DC
134 #define GL_MATRIX29_ARB                   0x88DD
135 #define GL_MATRIX30_ARB                   0x88DE
136 #define GL_MATRIX31_ARB                   0x88DF
137 
138 // GL_ARB_fragment_program
139 #define GL_FRAGMENT_PROGRAM_ARB           0x8804
140 #define GL_PROGRAM_ALU_INSTRUCTIONS_ARB   0x8805
141 #define GL_PROGRAM_TEX_INSTRUCTIONS_ARB   0x8806
142 #define GL_PROGRAM_TEX_INDIRECTIONS_ARB   0x8807
143 #define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
144 #define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
145 #define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
146 #define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
147 #define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
148 #define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
149 #define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
150 #define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
151 #define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
152 #define GL_MAX_TEXTURE_COORDS_ARB         0x8871
153 #define GL_MAX_TEXTURE_IMAGE_UNITS_ARB    0x8872
154 
155 // GL_VERSION_1_2
156 #define GL_UNSIGNED_BYTE_3_3_2            0x8032
157 #define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
158 #define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
159 #define GL_UNSIGNED_INT_8_8_8_8           0x8035
160 #define GL_UNSIGNED_INT_10_10_10_2        0x8036
161 #define GL_RESCALE_NORMAL                 0x803A
162 #define GL_TEXTURE_BINDING_3D             0x806A
163 #define GL_PACK_SKIP_IMAGES               0x806B
164 #define GL_PACK_IMAGE_HEIGHT              0x806C
165 #define GL_UNPACK_SKIP_IMAGES             0x806D
166 #define GL_UNPACK_IMAGE_HEIGHT            0x806E
167 #define GL_TEXTURE_3D                     0x806F
168 #define GL_PROXY_TEXTURE_3D               0x8070
169 #define GL_TEXTURE_DEPTH                  0x8071
170 #define GL_TEXTURE_WRAP_R                 0x8072
171 #define GL_MAX_3D_TEXTURE_SIZE            0x8073
172 #define GL_UNSIGNED_BYTE_2_3_3_REV        0x8362
173 #define GL_UNSIGNED_SHORT_5_6_5           0x8363
174 #define GL_UNSIGNED_SHORT_5_6_5_REV       0x8364
175 #define GL_UNSIGNED_SHORT_4_4_4_4_REV     0x8365
176 #define GL_UNSIGNED_SHORT_1_5_5_5_REV     0x8366
177 #define GL_UNSIGNED_INT_8_8_8_8_REV       0x8367
178 #define GL_UNSIGNED_INT_2_10_10_10_REV    0x8368
179 #define GL_BGR                            0x80E0
180 #define GL_BGRA                           0x80E1
181 #define GL_MAX_ELEMENTS_VERTICES          0x80E8
182 #define GL_MAX_ELEMENTS_INDICES           0x80E9
183 #define GL_CLAMP_TO_EDGE                  0x812F
184 #define GL_TEXTURE_MIN_LOD                0x813A
185 #define GL_TEXTURE_MAX_LOD                0x813B
186 #define GL_TEXTURE_BASE_LEVEL             0x813C
187 #define GL_TEXTURE_MAX_LEVEL              0x813D
188 #define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8
189 #define GL_SINGLE_COLOR                   0x81F9
190 #define GL_SEPARATE_SPECULAR_COLOR        0x81FA
191 #define GL_SMOOTH_POINT_SIZE_RANGE        0x0B12
192 #define GL_SMOOTH_POINT_SIZE_GRANULARITY  0x0B13
193 #define GL_SMOOTH_LINE_WIDTH_RANGE        0x0B22
194 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY  0x0B23
195 #define GL_ALIASED_POINT_SIZE_RANGE       0x846D
196 #define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
197 
198 // GL_VERSION_1_3
199 #define GL_TEXTURE0                       0x84C0
200 #define GL_TEXTURE1                       0x84C1
201 #define GL_TEXTURE2                       0x84C2
202 #define GL_TEXTURE3                       0x84C3
203 #define GL_TEXTURE4                       0x84C4
204 #define GL_TEXTURE5                       0x84C5
205 #define GL_TEXTURE6                       0x84C6
206 #define GL_TEXTURE7                       0x84C7
207 #define GL_TEXTURE8                       0x84C8
208 #define GL_TEXTURE9                       0x84C9
209 #define GL_TEXTURE10                      0x84CA
210 #define GL_TEXTURE11                      0x84CB
211 #define GL_TEXTURE12                      0x84CC
212 #define GL_TEXTURE13                      0x84CD
213 #define GL_TEXTURE14                      0x84CE
214 #define GL_TEXTURE15                      0x84CF
215 #define GL_TEXTURE16                      0x84D0
216 #define GL_TEXTURE17                      0x84D1
217 #define GL_TEXTURE18                      0x84D2
218 #define GL_TEXTURE19                      0x84D3
219 #define GL_TEXTURE20                      0x84D4
220 #define GL_TEXTURE21                      0x84D5
221 #define GL_TEXTURE22                      0x84D6
222 #define GL_TEXTURE23                      0x84D7
223 #define GL_TEXTURE24                      0x84D8
224 #define GL_TEXTURE25                      0x84D9
225 #define GL_TEXTURE26                      0x84DA
226 #define GL_TEXTURE27                      0x84DB
227 #define GL_TEXTURE28                      0x84DC
228 #define GL_TEXTURE29                      0x84DD
229 #define GL_TEXTURE30                      0x84DE
230 #define GL_TEXTURE31                      0x84DF
231 #define GL_ACTIVE_TEXTURE                 0x84E0
232 #define GL_CLIENT_ACTIVE_TEXTURE          0x84E1
233 #define GL_MAX_TEXTURE_UNITS              0x84E2
234 #define GL_TRANSPOSE_MODELVIEW_MATRIX     0x84E3
235 #define GL_TRANSPOSE_PROJECTION_MATRIX    0x84E4
236 #define GL_TRANSPOSE_TEXTURE_MATRIX       0x84E5
237 #define GL_TRANSPOSE_COLOR_MATRIX         0x84E6
238 #define GL_MULTISAMPLE                    0x809D
239 #define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
240 #define GL_SAMPLE_ALPHA_TO_ONE            0x809F
241 #define GL_SAMPLE_COVERAGE                0x80A0
242 #define GL_SAMPLE_BUFFERS                 0x80A8
243 #define GL_SAMPLES                        0x80A9
244 #define GL_SAMPLE_COVERAGE_VALUE          0x80AA
245 #define GL_SAMPLE_COVERAGE_INVERT         0x80AB
246 #define GL_MULTISAMPLE_BIT                0x20000000
247 #define GL_NORMAL_MAP                     0x8511
248 #define GL_REFLECTION_MAP                 0x8512
249 #define GL_TEXTURE_CUBE_MAP               0x8513
250 #define GL_TEXTURE_BINDING_CUBE_MAP       0x8514
251 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X    0x8515
252 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X    0x8516
253 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y    0x8517
254 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y    0x8518
255 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z    0x8519
256 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z    0x851A
257 #define GL_PROXY_TEXTURE_CUBE_MAP         0x851B
258 #define GL_MAX_CUBE_MAP_TEXTURE_SIZE      0x851C
259 #define GL_COMPRESSED_ALPHA               0x84E9
260 #define GL_COMPRESSED_LUMINANCE           0x84EA
261 #define GL_COMPRESSED_LUMINANCE_ALPHA     0x84EB
262 #define GL_COMPRESSED_INTENSITY           0x84EC
263 #define GL_COMPRESSED_RGB                 0x84ED
264 #define GL_COMPRESSED_RGBA                0x84EE
265 #define GL_TEXTURE_COMPRESSION_HINT       0x84EF
266 #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE  0x86A0
267 #define GL_TEXTURE_COMPRESSED             0x86A1
268 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
269 #define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
270 #define GL_CLAMP_TO_BORDER                0x812D
271 #define GL_CLAMP_TO_BORDER_SGIS           0x812D
272 #define GL_COMBINE                        0x8570
273 #define GL_COMBINE_RGB                    0x8571
274 #define GL_COMBINE_ALPHA                  0x8572
275 #define GL_SOURCE0_RGB                    0x8580
276 #define GL_SOURCE1_RGB                    0x8581
277 #define GL_SOURCE2_RGB                    0x8582
278 #define GL_SOURCE0_ALPHA                  0x8588
279 #define GL_SOURCE1_ALPHA                  0x8589
280 #define GL_SOURCE2_ALPHA                  0x858A
281 #define GL_OPERAND0_RGB                   0x8590
282 #define GL_OPERAND1_RGB                   0x8591
283 #define GL_OPERAND2_RGB                   0x8592
284 #define GL_OPERAND0_ALPHA                 0x8598
285 #define GL_OPERAND1_ALPHA                 0x8599
286 #define GL_OPERAND2_ALPHA                 0x859A
287 #define GL_RGB_SCALE                      0x8573
288 #define GL_ADD_SIGNED                     0x8574
289 #define GL_INTERPOLATE                    0x8575
290 #define GL_SUBTRACT                       0x84E7
291 #define GL_CONSTANT                       0x8576
292 #define GL_PRIMARY_COLOR                  0x8577
293 #define GL_PREVIOUS                       0x8578
294 #define GL_DOT3_RGB                       0x86AE
295 #define GL_DOT3_RGBA                      0x86AF
296 
297 // GL_EXT_bgra
298 #ifndef GL_EXT_bgra
299 #define GL_BGR_EXT                        0x80E0
300 #define GL_BGRA_EXT                       0x80E1
301 #endif
302 
303 // GL_ARB_texture_env_dot3
304 #define GL_DOT3_RGB_ARB                   0x86AE
305 #define GL_DOT3_RGBA_ARB                  0x86AF
306 
307 // GL_ARB_texture_cube_map
308 #define GL_NORMAL_MAP_ARB                 0x8511
309 #define GL_REFLECTION_MAP_ARB             0x8512
310 #define GL_TEXTURE_CUBE_MAP_ARB           0x8513
311 #define GL_TEXTURE_BINDING_CUBE_MAP_ARB   0x8514
312 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
313 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
314 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
315 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
316 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
317 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
318 #define GL_PROXY_TEXTURE_CUBE_MAP_ARB     0x851B
319 #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB  0x851C
320 
321 // GL_EXT_draw_range_elements
322 #define GL_MAX_ELEMENTS_VERTICES_EXT      0x80E8
323 #define GL_MAX_ELEMENTS_INDICES_EXT       0x80E9
324 
325 // GL_EXT_texture_filter_anisotropic
326 #define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
327 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
328 
329 // GL_EXT_stencil_two_side
330 #define GL_STENCIL_TEST_TWO_SIDE_EXT      0x8910
331 #define GL_ACTIVE_STENCIL_FACE_EXT        0x8911
332 
333 // GL_EXT_stencil_wrap
334 #define GL_INCR_WRAP_EXT                  0x8507
335 #define GL_DECR_WRAP_EXT                  0x8508
336 
337 // GL_ARB_multitexture
338 #define GL_TEXTURE0_ARB                   0x84C0
339 #define GL_TEXTURE1_ARB                   0x84C1
340 #define GL_TEXTURE2_ARB                   0x84C2
341 #define GL_TEXTURE3_ARB                   0x84C3
342 #define GL_TEXTURE4_ARB                   0x84C4
343 #define GL_TEXTURE5_ARB                   0x84C5
344 #define GL_TEXTURE6_ARB                   0x84C6
345 #define GL_TEXTURE7_ARB                   0x84C7
346 #define GL_TEXTURE8_ARB                   0x84C8
347 #define GL_TEXTURE9_ARB                   0x84C9
348 #define GL_TEXTURE10_ARB                  0x84CA
349 #define GL_TEXTURE11_ARB                  0x84CB
350 #define GL_TEXTURE12_ARB                  0x84CC
351 #define GL_TEXTURE13_ARB                  0x84CD
352 #define GL_TEXTURE14_ARB                  0x84CE
353 #define GL_TEXTURE15_ARB                  0x84CF
354 #define GL_TEXTURE16_ARB                  0x84D0
355 #define GL_TEXTURE17_ARB                  0x84D1
356 #define GL_TEXTURE18_ARB                  0x84D2
357 #define GL_TEXTURE19_ARB                  0x84D3
358 #define GL_TEXTURE20_ARB                  0x84D4
359 #define GL_TEXTURE21_ARB                  0x84D5
360 #define GL_TEXTURE22_ARB                  0x84D6
361 #define GL_TEXTURE23_ARB                  0x84D7
362 #define GL_TEXTURE24_ARB                  0x84D8
363 #define GL_TEXTURE25_ARB                  0x84D9
364 #define GL_TEXTURE26_ARB                  0x84DA
365 #define GL_TEXTURE27_ARB                  0x84DB
366 #define GL_TEXTURE28_ARB                  0x84DC
367 #define GL_TEXTURE29_ARB                  0x84DD
368 #define GL_TEXTURE30_ARB                  0x84DE
369 #define GL_TEXTURE31_ARB                  0x84DF
370 #define GL_ACTIVE_TEXTURE_ARB             0x84E0
371 #define GL_CLIENT_ACTIVE_TEXTURE_ARB      0x84E1
372 #define GL_MAX_TEXTURE_UNITS_ARB          0x84E2
373 
374 // GL_ARB_texture_compression
375 #define GL_COMPRESSED_ALPHA_ARB           0x84E9
376 #define GL_COMPRESSED_LUMINANCE_ARB       0x84EA
377 #define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
378 #define GL_COMPRESSED_INTENSITY_ARB       0x84EC
379 #define GL_COMPRESSED_RGB_ARB             0x84ED
380 #define GL_COMPRESSED_RGBA_ARB            0x84EE
381 #define GL_TEXTURE_COMPRESSION_HINT_ARB   0x84EF
382 #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
383 #define GL_TEXTURE_COMPRESSED_ARB         0x86A1
384 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
385 #define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
386 
387 // GL_S3_s3tc
388 #define GL_RGB_S3TC                       0x83A0
389 #define GL_RGB4_S3TC                      0x83A1
390 #define GL_RGBA_S3TC                      0x83A2
391 #define GL_RGBA4_S3TC                     0x83A3
392 
393 // GL_EXT_texture_compression_s3tc
394 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0
395 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  0x83F1
396 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT  0x83F2
397 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  0x83F3
398 
399 // GL_SGIS_multitexture
400 #define GL_TEXTURE0_SGIS					0x835E
401 #define GL_TEXTURE1_SGIS					0x835F
402 
403 // GL_SGIS_generate_mipmap
404 #define GL_GENERATE_MIPMAP_SGIS           0x8191
405 #define GL_GENERATE_MIPMAP_HINT_SGIS      0x8192
406 
407 // GL_SGIS_texture_edge_clamp
408 #define GL_CLAMP_TO_EDGE_SGIS             0x812F
409 
410 // GL_EXT_texture3D
411 #define GL_PACK_SKIP_IMAGES_EXT           0x806B
412 #define GL_PACK_IMAGE_HEIGHT_EXT          0x806C
413 #define GL_UNPACK_SKIP_IMAGES_EXT         0x806D
414 #define GL_UNPACK_IMAGE_HEIGHT_EXT        0x806E
415 #define GL_TEXTURE_3D_EXT                 0x806F
416 #define GL_PROXY_TEXTURE_3D_EXT           0x8070
417 #define GL_TEXTURE_DEPTH_EXT              0x8071
418 #define GL_TEXTURE_WRAP_R_EXT             0x8072
419 #define GL_MAX_3D_TEXTURE_SIZE_EXT        0x8073
420 
421 // GL_NV_texture_shader
422 #define GL_OFFSET_TEXTURE_RECTANGLE_NV    0x864C
423 #define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
424 #define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
425 #define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
426 #define GL_UNSIGNED_INT_S8_S8_8_8_NV      0x86DA
427 #define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV  0x86DB
428 #define GL_DSDT_MAG_INTENSITY_NV          0x86DC
429 #define GL_SHADER_CONSISTENT_NV           0x86DD
430 #define GL_TEXTURE_SHADER_NV              0x86DE
431 #define GL_SHADER_OPERATION_NV            0x86DF
432 #define GL_CULL_MODES_NV                  0x86E0
433 #define GL_OFFSET_TEXTURE_MATRIX_NV       0x86E1
434 #define GL_OFFSET_TEXTURE_SCALE_NV        0x86E2
435 #define GL_OFFSET_TEXTURE_BIAS_NV         0x86E3
436 #define GL_OFFSET_TEXTURE_2D_MATRIX_NV    GL_OFFSET_TEXTURE_MATRIX_NV
437 #define GL_OFFSET_TEXTURE_2D_SCALE_NV     GL_OFFSET_TEXTURE_SCALE_NV
438 #define GL_OFFSET_TEXTURE_2D_BIAS_NV      GL_OFFSET_TEXTURE_BIAS_NV
439 #define GL_PREVIOUS_TEXTURE_INPUT_NV      0x86E4
440 #define GL_CONST_EYE_NV                   0x86E5
441 #define GL_PASS_THROUGH_NV                0x86E6
442 #define GL_CULL_FRAGMENT_NV               0x86E7
443 #define GL_OFFSET_TEXTURE_2D_NV           0x86E8
444 #define GL_DEPENDENT_AR_TEXTURE_2D_NV     0x86E9
445 #define GL_DEPENDENT_GB_TEXTURE_2D_NV     0x86EA
446 #define GL_DOT_PRODUCT_NV                 0x86EC
447 #define GL_DOT_PRODUCT_DEPTH_REPLACE_NV   0x86ED
448 #define GL_DOT_PRODUCT_TEXTURE_2D_NV      0x86EE
449 #define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
450 #define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
451 #define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
452 #define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
453 #define GL_HILO_NV                        0x86F4
454 #define GL_DSDT_NV                        0x86F5
455 #define GL_DSDT_MAG_NV                    0x86F6
456 #define GL_DSDT_MAG_VIB_NV                0x86F7
457 #define GL_HILO16_NV                      0x86F8
458 #define GL_SIGNED_HILO_NV                 0x86F9
459 #define GL_SIGNED_HILO16_NV               0x86FA
460 #define GL_SIGNED_RGBA_NV                 0x86FB
461 #define GL_SIGNED_RGBA8_NV                0x86FC
462 #define GL_SIGNED_RGB_NV                  0x86FE
463 #define GL_SIGNED_RGB8_NV                 0x86FF
464 #define GL_SIGNED_LUMINANCE_NV            0x8701
465 #define GL_SIGNED_LUMINANCE8_NV           0x8702
466 #define GL_SIGNED_LUMINANCE_ALPHA_NV      0x8703
467 #define GL_SIGNED_LUMINANCE8_ALPHA8_NV    0x8704
468 #define GL_SIGNED_ALPHA_NV                0x8705
469 #define GL_SIGNED_ALPHA8_NV               0x8706
470 #define GL_SIGNED_INTENSITY_NV            0x8707
471 #define GL_SIGNED_INTENSITY8_NV           0x8708
472 #define GL_DSDT8_NV                       0x8709
473 #define GL_DSDT8_MAG8_NV                  0x870A
474 #define GL_DSDT8_MAG8_INTENSITY8_NV       0x870B
475 #define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV   0x870C
476 #define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
477 #define GL_HI_SCALE_NV                    0x870E
478 #define GL_LO_SCALE_NV                    0x870F
479 #define GL_DS_SCALE_NV                    0x8710
480 #define GL_DT_SCALE_NV                    0x8711
481 #define GL_MAGNITUDE_SCALE_NV             0x8712
482 #define GL_VIBRANCE_SCALE_NV              0x8713
483 #define GL_HI_BIAS_NV                     0x8714
484 #define GL_LO_BIAS_NV                     0x8715
485 #define GL_DS_BIAS_NV                     0x8716
486 #define GL_DT_BIAS_NV                     0x8717
487 #define GL_MAGNITUDE_BIAS_NV              0x8718
488 #define GL_VIBRANCE_BIAS_NV               0x8719
489 #define GL_TEXTURE_BORDER_VALUES_NV       0x871A
490 #define GL_TEXTURE_HI_SIZE_NV             0x871B
491 #define GL_TEXTURE_LO_SIZE_NV             0x871C
492 #define GL_TEXTURE_DS_SIZE_NV             0x871D
493 #define GL_TEXTURE_DT_SIZE_NV             0x871E
494 #define GL_TEXTURE_MAG_SIZE_NV            0x871F
495 
496 // GL_ARB_texture_env_combine
497 #define GL_COMBINE_ARB                    0x8570
498 #define GL_COMBINE_RGB_ARB                0x8571
499 #define GL_COMBINE_ALPHA_ARB              0x8572
500 #define GL_SOURCE0_RGB_ARB                0x8580
501 #define GL_SOURCE1_RGB_ARB                0x8581
502 #define GL_SOURCE2_RGB_ARB                0x8582
503 #define GL_SOURCE0_ALPHA_ARB              0x8588
504 #define GL_SOURCE1_ALPHA_ARB              0x8589
505 #define GL_SOURCE2_ALPHA_ARB              0x858A
506 #define GL_OPERAND0_RGB_ARB               0x8590
507 #define GL_OPERAND1_RGB_ARB               0x8591
508 #define GL_OPERAND2_RGB_ARB               0x8592
509 #define GL_OPERAND0_ALPHA_ARB             0x8598
510 #define GL_OPERAND1_ALPHA_ARB             0x8599
511 #define GL_OPERAND2_ALPHA_ARB             0x859A
512 #define GL_RGB_SCALE_ARB                  0x8573
513 #define GL_ADD_SIGNED_ARB                 0x8574
514 #define GL_INTERPOLATE_ARB                0x8575
515 #define GL_SUBTRACT_ARB                   0x84E7
516 #define GL_CONSTANT_ARB                   0x8576
517 #define GL_PRIMARY_COLOR_ARB              0x8577
518 #define GL_PREVIOUS_ARB                   0x8578
519 
520 // GL_NV_texture_env_combine4
521 #define GL_COMBINE4_NV                    0x8503
522 #define GL_SOURCE3_RGB_NV                 0x8583
523 #define GL_SOURCE3_ALPHA_NV               0x858B
524 #define GL_OPERAND3_RGB_NV                0x8593
525 #define GL_OPERAND3_ALPHA_NV              0x859B
526 
527 // GL_ARB_vertex_buffer_object
528 #define GL_ARRAY_BUFFER_ARB									0x8892
529 #define GL_ELEMENT_ARRAY_BUFFER_ARB							0x8893
530 #define GL_ARRAY_BUFFER_BINDING_ARB							0x8894
531 #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB					0x8895
532 #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB					0x8896
533 #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB					0x8897
534 #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB					0x8898
535 #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB					0x8899
536 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB			0x889A
537 #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB				0x889B
538 #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB			0x889C
539 #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB			0x889D
540 #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB					0x889E
541 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB			0x889F
542 #define GL_STREAM_DRAW_ARB									0x88E0
543 #define GL_STREAM_READ_ARB									0x88E1
544 #define GL_STREAM_COPY_ARB									0x88E2
545 #define GL_STATIC_DRAW_ARB									0x88E4
546 #define GL_STATIC_READ_ARB									0x88E5
547 #define GL_STATIC_COPY_ARB									0x88E6
548 #define GL_DYNAMIC_DRAW_ARB									0x88E8
549 #define GL_DYNAMIC_READ_ARB									0x88E9
550 #define GL_DYNAMIC_COPY_ARB									0x88EA
551 #define GL_READ_ONLY_ARB									0x88B8
552 #define GL_WRITE_ONLY_ARB									0x88B9
553 #define GL_READ_WRITE_ARB									0x88BA
554 #define GL_BUFFER_SIZE_ARB									0x8764
555 #define GL_BUFFER_USAGE_ARB									0x8765
556 #define GL_BUFFER_ACCESS_ARB								0x88BB
557 #define GL_BUFFER_MAPPED_ARB								0x88BC
558 #define GL_BUFFER_MAP_POINTER_ARB							0x88BD
559 
560 /*
561 =============================================================================
562 
563 	REFRESH INFO
564 
565 =============================================================================
566 */
567 
568 enum { // rendererClass_t
569 	REND_CLASS_DEFAULT,
570 	REND_CLASS_MCD,
571 
572 	REND_CLASS_3DLABS_GLINT_MX,
573 	REND_CLASS_3DLABS_PERMEDIA,
574 	REND_CLASS_3DLABS_REALIZM,
575 	REND_CLASS_ATI,
576 	REND_CLASS_ATI_RADEON,
577 	REND_CLASS_INTEL,
578 	REND_CLASS_NVIDIA,
579 	REND_CLASS_NVIDIA_GEFORCE,
580 	REND_CLASS_PMX,
581 	REND_CLASS_POWERVR_PCX1,
582 	REND_CLASS_POWERVR_PCX2,
583 	REND_CLASS_RENDITION,
584 	REND_CLASS_S3,
585 	REND_CLASS_SGI,
586 	REND_CLASS_SIS,
587 	REND_CLASS_VOODOO
588 };
589 
590 typedef struct refMedia_s {
591 	struct font_s		*defaultFont;
592 
593 	// This is hacky but necessary, fuck you Quake2.
594 	shader_t			*worldLavaCaustics;
595 	shader_t			*worldSlimeCaustics;
596 	shader_t			*worldWaterCaustics;
597 } refMedia_t;
598 
599 // FIXME: some of this can be moved to ri...
600 typedef struct refScene_s {
601 	// View
602 	cBspPlane_t			viewFrustum[5];
603 
604 	mat4x4_t			modelViewMatrix;
605 	mat4x4_t			projectionMatrix;
606 	mat4x4_t			worldViewMatrix;
607 
608 	qBool				mirrorView;
609 	qBool				portalView;
610 	vec3_t				portalOrigin;
611 	cBspPlane_t			clipPlane;
612 
613 	float				zFar;
614 
615 	refEntity_t			*defaultEntity;
616 	refModel_t			*defaultModel;
617 
618 	// World model
619 	refModel_t			*worldModel;
620 	refEntity_t			*worldEntity;
621 
622 	uint32				visFrameCount;	// Bumped when going to a new PVS
623 	int					viewCluster;
624 	int					oldViewCluster;
625 
626 	// Items
627 	uint32				numDecals;
628 	uint32				drawnDecals;
629 	refDecal_t			*decalList[MAX_REF_DECALS];
630 
631 	uint32				numEntities;
632 	refEntity_t			entityList[MAX_REF_ENTITIES];
633 
634 	uint32				numPolys;
635 	refPoly_t			*polyList[MAX_REF_POLYS];
636 
637 	uint32				numDLights;
638 	refDLight_t			dLightList[MAX_REF_DLIGHTS];
639 
640 	refLightStyle_t		lightStyles[MAX_CS_LIGHTSTYLES];
641 } refScene_t;
642 
643 enum {
644 	CULL_FAIL,
645 	CULL_PASS
646 };
647 
648 typedef struct refStats_s {
649 	// Totals
650 	uint32				numTris;
651 	uint32				numVerts;
652 	uint32				numElements;
653 
654 	uint32				meshCount;
655 	uint32				meshPasses;
656 
657 	uint32				stateChanges;
658 
659 	// Alias Models
660 	uint32				aliasElements;
661 	uint32				aliasPolys;
662 
663 	// Batching
664 	uint32				meshBatches;
665 	uint32				meshBatchFlush;
666 
667 	// Culling
668 	uint32				cullBounds[2];	// [CULL_FAIL|CULL_PASS]
669 	uint32				cullPlanar[2];	// [CULL_FAIL|CULL_PASS]
670 	uint32				cullRadius[2];	// [CULL_FAIL|CULL_PASS]
671 	uint32				cullSurf[2];	// [CULL_FAIL|CULL_PASS]
672 	uint32				cullVis[2];		// [CULL_FAIL|CULL_PASS]
673 
674 	// Image
675 	uint32				textureBinds;
676 	uint32				textureEnvChanges;
677 	uint32				textureUnitChanges;
678 
679 	uint32				texelsInUse;
680 	uint32				texturesInUse;
681 
682 	// World model
683 	uint32				worldElements;
684 	uint32				worldPolys;
685 
686 	// Time to process
687 	uint32				timeAddToList;
688 	uint32				timeSortList;
689 	uint32				timeDrawList;
690 
691 	uint32				timeMarkLeaves;
692 	uint32				timeMarkLights;
693 	uint32				timeRecurseWorld;
694 } refStats_t;
695 
696 typedef struct refRegist_s {
697 	qBool				inSequence;			// True when in a registration sequence
698 	uint32				registerFrame;		// Used to determine what's kept and what's not
699 
700 	// Fonts
701 	uint32				fontsReleased;
702 	uint32				fontsSeaked;
703 	uint32				fontsTouched;
704 
705 	// Images
706 	uint32				imagesReleased;
707 	uint32				imagesResampled;
708 	uint32				imagesSeaked;
709 	uint32				imagesTouched;
710 
711 	// Models
712 	uint32				modelsReleased;
713 	uint32				modelsSeaked;
714 	uint32				modelsTouched;
715 
716 	// Shaders
717 	uint32				shadersReleased;
718 	uint32				shadersSeaked;
719 	uint32				shadersTouched;
720 } refRegist_t;
721 
722 typedef struct refInfo_s {
723 	// Refresh information
724 	rendererClass_t		renderClass;
725 
726 	const byte			*rendererString;
727 	const byte			*vendorString;
728 	const byte			*versionString;
729 	const byte			*extensionString;
730 
731 	int					lastValidMode;
732 
733 	// Frame information
734 	float				cameraSeparation;
735 	uint32				frameCount;
736 
737 	// Hardware gamma
738 	qBool				rampDownloaded;
739 	uint16				originalRamp[768];
740 	uint16				gammaRamp[768];
741 
742 	// PFD Stuff
743 	qBool				useStencil;
744 
745 	byte				cAlphaBits;
746 	byte				cColorBits;
747 	byte				cDepthBits;
748 	byte				cStencilBits;
749 
750 	// Texture
751 	float				inverseIntensity;
752 
753 	GLint				texMinFilter;
754 	GLint				texMagFilter;
755 
756 	int					rgbFormat;
757 	int					rgbaFormat;
758 
759 	int					rgbFormatCompressed;
760 	int					rgbaFormatCompressed;
761 
762 	float				pow2MapOvrbr;
763 
764 	// Internal textures
765 	image_t				*noTexture;			// use for bad textures
766 	image_t				*whiteTexture;		// used in shaders/fallback
767 	image_t				*blackTexture;		// used in shaders/fallback
768 	image_t				*cinTexture;		// allocates memory on load as to not every cin frame
769 	image_t				*dLightTexture;		// dynamic light texture for q3 bsp
770 	image_t				*fogTexture;		// fog texture for q3 bsp
771 
772 	// Memory management
773 	struct memPool_s	*decalSysPool;
774 	struct memPool_s	*fontSysPool;
775 	struct memPool_s	*genericPool;
776 	struct memPool_s	*imageSysPool;
777 	struct memPool_s	*lightSysPool;
778 	struct memPool_s	*modelSysPool;
779 	struct memPool_s	*programSysPool;
780 	struct memPool_s	*shaderSysPool;
781 
782 	// Misc
783 	refConfig_t			config;			// Information output to the client/cgame
784 	refDef_t			def;			// Current refDef scene
785 	refMedia_t			media;			// Local media
786 	refRegist_t			reg;			// Registration counters
787 	refScene_t			scn;			// Local scene information
788 	refStats_t			pc;				// Performance counters
789 } refInfo_t;
790 
791 extern refInfo_t	ri;
792 
793 /*
794 =============================================================================
795 
796 	CVARS
797 
798 =============================================================================
799 */
800 
801 extern cVar_t	*e_test_0;
802 extern cVar_t	*e_test_1;
803 
804 extern cVar_t	*intensity;
805 
806 extern cVar_t	*gl_bitdepth;
807 extern cVar_t	*gl_clear;
808 extern cVar_t	*gl_cull;
809 extern cVar_t	*gl_drawbuffer;
810 extern cVar_t	*gl_driver;
811 extern cVar_t	*gl_dynamic;
812 extern cVar_t	*gl_errorcheck;
813 
814 extern cVar_t	*r_ext_maxAnisotropy;
815 
816 extern cVar_t	*gl_finish;
817 extern cVar_t	*gl_flashblend;
818 extern cVar_t	*gl_jpgquality;
819 extern cVar_t	*gl_lightmap;
820 extern cVar_t	*gl_lockpvs;
821 extern cVar_t	*gl_log;
822 extern cVar_t	*gl_maxTexSize;
823 extern cVar_t	*gl_mode;
824 extern cVar_t	*gl_modulate;
825 
826 extern cVar_t	*gl_screenshot;
827 extern cVar_t	*gl_shadows;
828 extern cVar_t	*gl_shownormals;
829 extern cVar_t	*gl_showtris;
830 extern cVar_t	*gl_stencilbuffer;
831 extern cVar_t	*gl_texturemode;
832 
833 extern cVar_t	*qgl_debug;
834 
835 extern cVar_t	*r_caustics;
836 extern cVar_t	*r_colorMipLevels;
837 extern cVar_t	*r_debugBatching;
838 extern cVar_t	*r_debugCulling;
839 extern cVar_t	*r_debugLighting;
840 extern cVar_t	*r_debugSorting;
841 extern cVar_t	*r_defaultFont;
842 extern cVar_t	*r_detailTextures;
843 extern cVar_t	*r_displayFreq;
844 extern cVar_t	*r_drawDecals;
845 extern cVar_t	*r_drawEntities;
846 extern cVar_t	*r_drawPolys;
847 extern cVar_t	*r_drawworld;
848 extern cVar_t	*r_facePlaneCull;
849 extern cVar_t	*r_flares;
850 extern cVar_t	*r_flareFade;
851 extern cVar_t	*r_flareSize;
852 extern cVar_t	*r_fontScale;
853 extern cVar_t	*r_fullbright;
854 extern cVar_t	*r_hwGamma;
855 extern cVar_t	*r_lerpmodels;
856 extern cVar_t	*r_lightlevel;	// FIXME: This is a HACK to get the client's light level
857 extern cVar_t	*r_lmMaxBlockSize;
858 extern cVar_t	*r_lmModulate;
859 extern cVar_t	*r_lmPacking;
860 extern cVar_t	*r_noCull;
861 extern cVar_t	*r_noRefresh;
862 extern cVar_t	*r_noVis;
863 extern cVar_t	*r_offsetFactor;
864 extern cVar_t	*r_offsetUnits;
865 extern cVar_t	*r_patchDivLevel;
866 extern cVar_t	*r_roundImagesDown;
867 extern cVar_t	*r_skipBackend;
868 extern cVar_t	*r_speeds;
869 extern cVar_t	*r_sphereCull;
870 extern cVar_t	*r_swapInterval;
871 extern cVar_t	*r_textureBits;
872 extern cVar_t	*r_times;
873 extern cVar_t	*r_vertexLighting;
874 extern cVar_t	*r_zFarAbs;
875 extern cVar_t	*r_zFarMin;
876 extern cVar_t	*r_zNear;
877 
878 extern cVar_t	*r_alphabits;
879 extern cVar_t	*r_colorbits;
880 extern cVar_t	*r_depthbits;
881 extern cVar_t	*r_stencilbits;
882 extern cVar_t	*cl_stereo;
883 extern cVar_t	*gl_allow_software;
884 extern cVar_t	*gl_stencilbuffer;
885 
886 extern cVar_t	*vid_gammapics;
887 extern cVar_t	*vid_gamma;
888 extern cVar_t	*vid_width;
889 extern cVar_t	*vid_height;
890 
891 extern cVar_t	*intensity;
892 
893 extern cVar_t	*gl_nobind;
894 extern cVar_t	*gl_picmip;
895 extern cVar_t	*gl_screenshot;
896 extern cVar_t	*gl_texturemode;
897 
898 /*
899 =============================================================================
900 
901 	SUPPORTING FUNCTIONS
902 
903 =============================================================================
904 */
905 
906 //
907 // r_math.c
908 //
909 
910 void		R_SetupProjectionMatrix (refDef_t *rd, mat4x4_t m);
911 void		R_SetupModelviewMatrix (refDef_t *rd, mat4x4_t m);
912 
913 void		Matrix4_Multiply_Vector (const mat4x4_t m, const vec4_t v, vec4_t out);
914 
915 //
916 // rb_batch.c
917 //
918 
919 qBool		RB_BackendOverflow (int numVerts, int numIndexes);
920 qBool		RB_InvalidMesh (const mesh_t *mesh);
921 void		RB_PushMesh (mesh_t *mesh, meshFeatures_t meshFeatures);
922 
923 //
924 // rf_init.c
925 //
926 
927 qBool		R_GetInfoForMode (int mode, int *width, int *height);
928 
929 //
930 // rb_light.c
931 //
932 
933 void		RB_DrawDLights (void);
934 
935 //
936 // rb_math.c
937 //
938 
939 float		RB_FastSin (float t);
940 
941 //
942 // rb_render.c
943 //
944 
945 void		RB_LockArrays (int numVerts);
946 void		RB_UnlockArrays (void);
947 void		RB_ResetPointers (void);
948 
949 void		RB_RenderMeshBuffer (meshBuffer_t *mb, qBool shadowPass);
950 void		RB_FinishRendering (void);
951 
952 void		RB_BeginTriangleOutlines (void);
953 void		RB_EndTriangleOutlines (void);
954 
955 void		RB_BeginFrame (void);
956 void		RB_EndFrame (void);
957 
958 void		RB_Init (void);
959 void		RB_Shutdown (void);
960 
961 //
962 // rb_shadow.c
963 //
964 
965 #ifdef SHADOW_VOLUMES
966 void		RB_SetShadowState (qBool start);
967 void		RB_DrawShadowVolumes (mesh_t *mesh, refEntity_t *ent, vec3_t mins, vec3_t maxs, float radius);
968 void		RB_ShadowBlend (void);
969 #endif
970 
971 void		RB_SimpleShadow (refEntity_t *ent, vec3_t shadowSpot);
972 
973 //
974 // rb_state.c
975 //
976 
977 void		RB_BindTexture (image_t *image);
978 
979 void		RB_SetupGL2D (void);
980 void		RB_SetupGL3D (void);
981 void		RB_ClearBuffers (void);
982 
983 void		RB_SetDefaultState (void);
984 
985 //
986 // rf_cull.c
987 //
988 
989 void		R_SetupFrustum (void);
990 
991 qBool		R_CullBox (vec3_t mins, vec3_t maxs, int clipFlags);
992 qBool		R_CullSphere (const vec3_t origin, const float radius, int clipFlags);
993 qBool		R_CullNode (struct mBspNode_s *node);
994 qBool		R_CullSurface (struct mBspSurface_s *surf);
995 
996 //
997 // rf_decal.c
998 //
999 
1000 void		R_AddDecalsToList (void);
1001 void		R_PushDecal (meshBuffer_t *mb, meshFeatures_t features);
1002 qBool		R_DecalOverflow (meshBuffer_t *mb);
1003 void		R_DecalInit (void);
1004 void		R_ClearDecals (void);
1005 
1006 //
1007 // rf_font.c
1008 //
1009 
1010 void		R_EndFontRegistration (void);
1011 
1012 void		R_CheckFont (void);
1013 
1014 void		R_FontInit (void);
1015 void		R_FontShutdown (void);
1016 
1017 //
1018 // rf_light.c
1019 //
1020 
1021 void		R_Q2BSP_MarkWorldLights (void);
1022 void		R_Q2BSP_MarkBModelLights (refEntity_t *ent, vec3_t mins, vec3_t maxs);
1023 
1024 void		R_Q2BSP_UpdateLightmap (mBspSurface_t *surf);
1025 void		R_Q2BSP_BeginBuildingLightmaps (void);
1026 void		R_Q2BSP_CreateSurfaceLightmap (mBspSurface_t *surf);
1027 void		R_Q2BSP_EndBuildingLightmaps (void);
1028 
1029 void		R_Q3BSP_MarkWorldLights (void);
1030 void		R_Q3BSP_MarkBModelLights (refEntity_t *ent, vec3_t mins, vec3_t maxs);
1031 
1032 void		R_Q3BSP_BuildLightmaps (int numLightmaps, int w, int h, const byte *data, mQ3BspLightmapRect_t *rects);
1033 
1034 void		R_LightBounds (const vec3_t origin, float intensity, vec3_t mins, vec3_t maxs);
1035 void		R_LightPoint (vec3_t point, vec3_t light);
1036 void		R_SetLightLevel (void);
1037 
1038 void		R_TouchLightmaps (void);
1039 
1040 qBool		R_ShadowForEntity (refEntity_t *ent, vec3_t shadowSpot);
1041 void		R_LightForEntity (refEntity_t *ent, int numVerts, byte *bArray);
1042 
1043 //
1044 // rf_main.c
1045 //
1046 
1047 void		R_PushPoly (meshBuffer_t *mb, meshFeatures_t features);
1048 qBool		R_PolyOverflow (meshBuffer_t *mb);
1049 void		R_PolyInit (void);
1050 
1051 void		R_EntityInit (void);
1052 
1053 void		R_TransformToScreen_Vec3 (vec3_t in, vec3_t out);
1054 void		R_RenderToList (refDef_t *rd, meshList_t *list);
1055 
1056 void		GL_CheckForError (char *where);
1057 
1058 //
1059 // rf_sky.c
1060 //
1061 
1062 #define SKY_MAXCLIPVERTS	64
1063 #define SKY_BOXSIZE			8192
1064 
1065 void		R_ClipSkySurface (mBspSurface_t *surf);
1066 void		R_AddSkyToList (void);
1067 
1068 void		R_ClearSky (void);
1069 void		R_DrawSky (meshBuffer_t *mb);
1070 
1071 void		R_SetSky (char *name, float rotate, vec3_t axis);
1072 
1073 void		R_SkyInit (void);
1074 void		R_SkyShutdown (void);
1075 
1076 //
1077 // rf_world.c
1078 //
1079 
1080 void		R_AddQ2BrushModel (refEntity_t *ent);
1081 void		R_AddQ3BrushModel (refEntity_t *ent);
1082 void		R_AddWorldToList (void);
1083 
1084 void		R_WorldInit (void);
1085 void		R_WorldShutdown (void);
1086 
1087 /*
1088 =============================================================================
1089 
1090 	IMPLEMENTATION SPECIFIC
1091 
1092 =============================================================================
1093 */
1094 
1095 extern cVar_t	*vid_fullscreen;
1096 extern cVar_t	*vid_xpos;
1097 extern cVar_t	*vid_ypos;
1098 
1099 //
1100 // glimp_imp.c
1101 //
1102 
1103 void	GLimp_BeginFrame (void);
1104 void	GLimp_EndFrame (void);
1105 
1106 void	GLimp_AppActivate (qBool active);
1107 qBool	GLimp_GetGammaRamp (uint16 *ramp);
1108 void	GLimp_SetGammaRamp (uint16 *ramp);
1109 
1110 void	GLimp_Shutdown (qBool full);
1111 qBool	GLimp_Init (void);
1112 qBool	GLimp_AttemptMode (qBool fullScreen, int width, int height);
1113