vkQuake2 doxygen  1.0 dev
gl_rmain.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 Copyright (C) 2018-2019 Krzysztof Kondrak
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14 See the GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 */
21 // r_main.c
22 #include "gl_local.h"
23 #include <ctype.h>
24 
25 void R_Clear (void);
26 
27 #ifdef __linux__
28 extern char *strlwr (char *s);
29 #endif
30 
32 
34 
36 
38 
40 
43 
44 image_t *r_notexture; // use for bad textures
45 image_t *r_particletexture; // little dot for particles
46 
49 
51 
52 int r_visframecount; // bumped when going to a new PVS
53 int r_framecount; // used for dlight push checking
54 
56 
57 float v_blend[4]; // final blending color
58 
59 void GL_Strings_f( void );
60 
61 //
62 // view origin
63 //
68 
69 float r_world_matrix[16];
71 
72 //
73 // screen size info
74 //
76 
78 
88 
89 cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light level
90 
93 
95 
102 
108 
137 
139 
143 
144 /*
145 =================
146 R_CullBox
147 
148 Returns true if the box is completely outside the frustom
149 =================
150 */
152 {
153  int i;
154 
155  if (r_nocull->value)
156  return false;
157 
158  for (i=0 ; i<4 ; i++)
159  if ( BOX_ON_PLANE_SIDE(mins, maxs, &frustum[i]) == 2)
160  return true;
161  return false;
162 }
163 
164 
166 {
167  qglTranslatef (e->origin[0], e->origin[1], e->origin[2]);
168 
169  qglRotatef (e->angles[1], 0, 0, 1);
170  qglRotatef (-e->angles[0], 0, 1, 0);
171  qglRotatef (-e->angles[2], 1, 0, 0);
172 }
173 
174 /*
175 =============================================================
176 
177  SPRITE MODELS
178 
179 =============================================================
180 */
181 
182 
183 /*
184 =================
185 R_DrawSpriteModel
186 
187 =================
188 */
190 {
191  float alpha = 1.0F;
192  vec3_t point;
193  dsprframe_t *frame;
194  float *up, *right;
195  dsprite_t *psprite;
196 
197  // don't even bother culling, because it's just a single
198  // polygon without a surface cache
199 
200  psprite = (dsprite_t *)currentmodel->extradata;
201 
202 #if 0
203  if (e->frame < 0 || e->frame >= psprite->numframes)
204  {
205  ri.Con_Printf (PRINT_ALL, "no such sprite frame %i\n", e->frame);
206  e->frame = 0;
207  }
208 #endif
209  e->frame %= psprite->numframes;
210 
211  frame = &psprite->frames[e->frame];
212 
213 #if 0
214  if (psprite->type == SPR_ORIENTED)
215  { // bullet marks on walls
216  vec3_t v_forward, v_right, v_up;
217 
218  AngleVectors (currententity->angles, v_forward, v_right, v_up);
219  up = v_up;
220  right = v_right;
221  }
222  else
223 #endif
224  { // normal sprite
225  up = vup;
226  right = vright;
227  }
228 
229  if ( e->flags & RF_TRANSLUCENT )
230  alpha = e->alpha;
231 
232  if ( alpha != 1.0F )
233  qglEnable( GL_BLEND );
234 
235  qglColor4f( 1, 1, 1, alpha );
236 
238 
239  GL_TexEnv( GL_MODULATE );
240 
241  if ( alpha == 1.0 )
242  qglEnable (GL_ALPHA_TEST);
243  else
244  qglDisable( GL_ALPHA_TEST );
245 
246  qglBegin (GL_QUADS);
247 
248  qglTexCoord2f (0, 1);
249  VectorMA (e->origin, -frame->origin_y, up, point);
250  VectorMA (point, -frame->origin_x, right, point);
251  qglVertex3fv (point);
252 
253  qglTexCoord2f (0, 0);
254  VectorMA (e->origin, frame->height - frame->origin_y, up, point);
255  VectorMA (point, -frame->origin_x, right, point);
256  qglVertex3fv (point);
257 
258  qglTexCoord2f (1, 0);
259  VectorMA (e->origin, frame->height - frame->origin_y, up, point);
260  VectorMA (point, frame->width - frame->origin_x, right, point);
261  qglVertex3fv (point);
262 
263  qglTexCoord2f (1, 1);
264  VectorMA (e->origin, -frame->origin_y, up, point);
265  VectorMA (point, frame->width - frame->origin_x, right, point);
266  qglVertex3fv (point);
267 
268  qglEnd ();
269 
270  qglDisable (GL_ALPHA_TEST);
271  GL_TexEnv( GL_REPLACE );
272 
273  if ( alpha != 1.0F )
274  qglDisable( GL_BLEND );
275 
276  qglColor4f( 1, 1, 1, 1 );
277 }
278 
279 //==================================================================================
280 
281 /*
282 =============
283 R_DrawNullModel
284 =============
285 */
286 void R_DrawNullModel (void)
287 {
289  int i;
290 
292  shadelight[0] = shadelight[1] = shadelight[2] = 1.0F;
293  else
295 
296  qglPushMatrix ();
298 
299  qglDisable (GL_TEXTURE_2D);
300  qglColor3fv (shadelight);
301 
302  qglBegin (GL_TRIANGLE_FAN);
303  qglVertex3f (0, 0, -16);
304  for (i=0 ; i<=4 ; i++)
305  qglVertex3f (16*cos(i*M_PI/2), 16*sin(i*M_PI/2), 0);
306  qglEnd ();
307 
308  qglBegin (GL_TRIANGLE_FAN);
309  qglVertex3f (0, 0, 16);
310  for (i=4 ; i>=0 ; i--)
311  qglVertex3f (16*cos(i*M_PI/2), 16*sin(i*M_PI/2), 0);
312  qglEnd ();
313 
314  qglColor3f (1,1,1);
315  qglPopMatrix ();
316  qglEnable (GL_TEXTURE_2D);
317 }
318 
319 /*
320 =============
321 R_DrawEntitiesOnList
322 =============
323 */
325 {
326  int i;
327 
328  if (!r_drawentities->value)
329  return;
330 
331  // draw non-transparent first
332  for (i=0 ; i<r_newrefdef.num_entities ; i++)
333  {
336  continue; // solid
337 
338  if ( currententity->flags & RF_BEAM )
339  {
341  }
342  else
343  {
345  if (!currentmodel)
346  {
347  R_DrawNullModel ();
348  continue;
349  }
350  switch (currentmodel->type)
351  {
352  case mod_alias:
354  break;
355  case mod_brush:
357  break;
358  case mod_sprite:
360  break;
361  default:
362  ri.Sys_Error (ERR_DROP, "Bad modeltype");
363  break;
364  }
365  }
366  }
367 
368  // draw transparent entities
369  // we could sort these if it ever becomes a problem...
370  qglDepthMask (0); // no z writes
371  for (i=0 ; i<r_newrefdef.num_entities ; i++)
372  {
375  continue; // solid
376 
377  if ( currententity->flags & RF_BEAM )
378  {
380  }
381  else
382  {
384 
385  if (!currentmodel)
386  {
387  R_DrawNullModel ();
388  continue;
389  }
390  switch (currentmodel->type)
391  {
392  case mod_alias:
394  break;
395  case mod_brush:
397  break;
398  case mod_sprite:
400  break;
401  default:
402  ri.Sys_Error (ERR_DROP, "Bad modeltype");
403  break;
404  }
405  }
406  }
407  qglDepthMask (1); // back to writing
408 
409 }
410 
411 /*
412 ** GL_DrawParticles
413 **
414 */
415 void GL_DrawParticles( int num_particles, const particle_t particles[], const unsigned colortable[768] )
416 {
417  const particle_t *p;
418  int i;
419  vec3_t up, right;
420  float scale;
421  byte color[4];
422 
424  qglDepthMask( GL_FALSE ); // no z buffering
425  qglEnable( GL_BLEND );
426  GL_TexEnv( GL_MODULATE );
427  qglBegin( GL_TRIANGLES );
428 
429  VectorScale (vup, 1.5, up);
430  VectorScale (vright, 1.5, right);
431 
432  for ( p = particles, i=0 ; i < num_particles ; i++,p++)
433  {
434  // hack a scale up to keep particles from disapearing
435  scale = ( p->origin[0] - r_origin[0] ) * vpn[0] +
436  ( p->origin[1] - r_origin[1] ) * vpn[1] +
437  ( p->origin[2] - r_origin[2] ) * vpn[2];
438 
439  if (scale < 20)
440  scale = 1;
441  else
442  scale = 1 + scale * 0.004;
443 
444  *(int *)color = colortable[p->color];
445  color[3] = p->alpha*255;
446 
447  qglColor4ubv( color );
448 
449  qglTexCoord2f( 0.0625, 0.0625 );
450  qglVertex3fv( p->origin );
451 
452  qglTexCoord2f( 1.0625, 0.0625 );
453  qglVertex3f( p->origin[0] + up[0]*scale,
454  p->origin[1] + up[1]*scale,
455  p->origin[2] + up[2]*scale);
456 
457  qglTexCoord2f( 0.0625, 1.0625 );
458  qglVertex3f( p->origin[0] + right[0]*scale,
459  p->origin[1] + right[1]*scale,
460  p->origin[2] + right[2]*scale);
461  }
462 
463  qglEnd ();
464  qglDisable( GL_BLEND );
465  qglColor4f( 1,1,1,1 );
466  qglDepthMask( 1 ); // back to normal Z buffering
467  GL_TexEnv( GL_REPLACE );
468 }
469 
470 /*
471 ===============
472 R_DrawParticles
473 ===============
474 */
475 void R_DrawParticles (void)
476 {
477  if ( gl_ext_pointparameters->value && qglPointParameterfEXT )
478  {
479  int i;
480  unsigned char color[4];
481  const particle_t *p;
482 
483  qglDepthMask( GL_FALSE );
484  qglEnable( GL_BLEND );
485  qglDisable( GL_TEXTURE_2D );
486 
487  qglPointSize( gl_particle_size->value );
488 
489  qglBegin( GL_POINTS );
490  for ( i = 0, p = r_newrefdef.particles; i < r_newrefdef.num_particles; i++, p++ )
491  {
492  *(int *)color = d_8to24table[p->color];
493  color[3] = p->alpha*255;
494 
495  qglColor4ubv( color );
496 
497  qglVertex3fv( p->origin );
498  }
499  qglEnd();
500 
501  qglDisable( GL_BLEND );
502  qglColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
503  qglDepthMask( GL_TRUE );
504  qglEnable( GL_TEXTURE_2D );
505 
506  }
507  else
508  {
510  }
511 }
512 
513 /*
514 ============
515 R_PolyBlend
516 ============
517 */
518 void R_PolyBlend (void)
519 {
520  if (!gl_polyblend->value)
521  return;
522  if (!v_blend[3])
523  return;
524 
525  qglDisable (GL_ALPHA_TEST);
526  qglEnable (GL_BLEND);
527  qglDisable (GL_DEPTH_TEST);
528  qglDisable (GL_TEXTURE_2D);
529 
530  qglLoadIdentity ();
531 
532  // FIXME: get rid of these
533  qglRotatef (-90, 1, 0, 0); // put Z going up
534  qglRotatef (90, 0, 0, 1); // put Z going up
535 
536  qglColor4fv (v_blend);
537 
538  qglBegin (GL_QUADS);
539 
540  qglVertex3f (10, 100, 100);
541  qglVertex3f (10, -100, 100);
542  qglVertex3f (10, -100, -100);
543  qglVertex3f (10, 100, -100);
544  qglEnd ();
545 
546  qglDisable (GL_BLEND);
547  qglEnable (GL_TEXTURE_2D);
548  qglEnable (GL_ALPHA_TEST);
549 
550  qglColor4f(1,1,1,1);
551 }
552 
553 //=======================================================================
554 
556 {
557  int bits, j;
558 
559  // for fast box on planeside test
560 
561  bits = 0;
562  for (j=0 ; j<3 ; j++)
563  {
564  if (out->normal[j] < 0)
565  bits |= 1<<j;
566  }
567  return bits;
568 }
569 
570 
571 void R_SetFrustum (void)
572 {
573  int i;
574 
575 #if 0
576  /*
577  ** this code is wrong, since it presume a 90 degree FOV both in the
578  ** horizontal and vertical plane
579  */
580  // front side is visible
581  VectorAdd (vpn, vright, frustum[0].normal);
582  VectorSubtract (vpn, vright, frustum[1].normal);
583  VectorAdd (vpn, vup, frustum[2].normal);
584  VectorSubtract (vpn, vup, frustum[3].normal);
585 
586  // we theoretically don't need to normalize these vectors, but I do it
587  // anyway so that debugging is a little easier
588  VectorNormalize( frustum[0].normal );
589  VectorNormalize( frustum[1].normal );
590  VectorNormalize( frustum[2].normal );
591  VectorNormalize( frustum[3].normal );
592 #else
593  // rotate VPN right by FOV_X/2 degrees
594  RotatePointAroundVector( frustum[0].normal, vup, vpn, -(90-r_newrefdef.fov_x / 2 ) );
595  // rotate VPN left by FOV_X/2 degrees
596  RotatePointAroundVector( frustum[1].normal, vup, vpn, 90-r_newrefdef.fov_x / 2 );
597  // rotate VPN up by FOV_X/2 degrees
599  // rotate VPN down by FOV_X/2 degrees
600  RotatePointAroundVector( frustum[3].normal, vright, vpn, -( 90 - r_newrefdef.fov_y / 2 ) );
601 #endif
602 
603  for (i=0 ; i<4 ; i++)
604  {
606  frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
608  }
609 }
610 
611 //=======================================================================
612 
613 /*
614 ===============
615 R_SetupFrame
616 ===============
617 */
618 void R_SetupFrame (void)
619 {
620  int i;
621  mleaf_t *leaf;
622 
623  r_framecount++;
624 
625 // build the transformation matrix for the given view angles
627 
629 
630 // current viewcluster
631  if ( !( r_newrefdef.rdflags & RDF_NOWORLDMODEL ) )
632  {
637 
638  // check above and below so crossing solid water doesn't draw wrong
639  if (!leaf->contents)
640  { // look down a bit
641  vec3_t temp;
642 
643  VectorCopy (r_origin, temp);
644  temp[2] -= 16;
645  leaf = Mod_PointInLeaf (temp, r_worldmodel);
646  if ( !(leaf->contents & CONTENTS_SOLID) &&
647  (leaf->cluster != r_viewcluster2) )
648  r_viewcluster2 = leaf->cluster;
649  }
650  else
651  { // look up a bit
652  vec3_t temp;
653 
654  VectorCopy (r_origin, temp);
655  temp[2] += 16;
656  leaf = Mod_PointInLeaf (temp, r_worldmodel);
657  if ( !(leaf->contents & CONTENTS_SOLID) &&
658  (leaf->cluster != r_viewcluster2) )
659  r_viewcluster2 = leaf->cluster;
660  }
661  }
662 
663  for (i=0 ; i<4 ; i++)
665 
666  c_brush_polys = 0;
667  c_alias_polys = 0;
668 
669  // clear out the portion of the screen that the NOWORLDMODEL defines
671  {
672  qglEnable( GL_SCISSOR_TEST );
673  qglClearColor( 0.3, 0.3, 0.3, 1 );
675  qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
676  qglClearColor( 1, 0, 0.5, 0.5 );
677  qglDisable( GL_SCISSOR_TEST );
678  }
679 }
680 
681 
682 void MYgluPerspective( GLdouble fovy, GLdouble aspect,
683  GLdouble zNear, GLdouble zFar )
684 {
685  GLdouble xmin, xmax, ymin, ymax;
686 
687  ymax = zNear * tan( fovy * M_PI / 360.0 );
688  ymin = -ymax;
689 
690  xmin = ymin * aspect;
691  xmax = ymax * aspect;
692 
693  xmin += -( 2 * gl_state.camera_separation ) / zNear;
694  xmax += -( 2 * gl_state.camera_separation ) / zNear;
695 
696  qglFrustum( xmin, xmax, ymin, ymax, zNear, zFar );
697 }
698 
699 
700 /*
701 =============
702 R_SetupGL
703 =============
704 */
705 void R_SetupGL (void)
706 {
707  float screenaspect;
708 // float yfov;
709  int x, x2, y2, y, w, h;
710 
711  //
712  // set up viewport
713  //
714  x = floor(r_newrefdef.x * vid.width / vid.width);
715  x2 = ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
716  y = floor(vid.height - r_newrefdef.y * vid.height / vid.height);
718 
719  w = x2 - x;
720  h = y - y2;
721 
722  qglViewport (x, y2, w, h);
723 
724  //
725  // set up projection matrix
726  //
727  screenaspect = (float)r_newrefdef.width/r_newrefdef.height;
728 // yfov = 2*atan((float)r_newrefdef.height/r_newrefdef.width)*180/M_PI;
729  qglMatrixMode(GL_PROJECTION);
730  qglLoadIdentity ();
731  MYgluPerspective (r_newrefdef.fov_y, screenaspect, 4, 4096);
732 
733  qglCullFace(GL_FRONT);
734 
735  qglMatrixMode(GL_MODELVIEW);
736  qglLoadIdentity ();
737 
738  qglRotatef (-90, 1, 0, 0); // put Z going up
739  qglRotatef (90, 0, 0, 1); // put Z going up
740  qglRotatef (-r_newrefdef.viewangles[2], 1, 0, 0);
741  qglRotatef (-r_newrefdef.viewangles[0], 0, 1, 0);
742  qglRotatef (-r_newrefdef.viewangles[1], 0, 0, 1);
743  qglTranslatef (-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]);
744 
745 // if ( gl_state.camera_separation != 0 && gl_state.stereo_enabled )
746 // qglTranslatef ( gl_state.camera_separation, 0, 0 );
747 
748  qglGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
749 
750  //
751  // set drawing parms
752  //
753  if (gl_cull->value)
754  qglEnable(GL_CULL_FACE);
755  else
756  qglDisable(GL_CULL_FACE);
757 
758  qglDisable(GL_BLEND);
759  qglDisable(GL_ALPHA_TEST);
760  qglEnable(GL_DEPTH_TEST);
761 }
762 
763 /*
764 =============
765 R_Clear
766 =============
767 */
768 void R_Clear (void)
769 {
770  if (gl_ztrick->value)
771  {
772  static int trickframe;
773 
774  if (gl_clear->value)
775  qglClear (GL_COLOR_BUFFER_BIT);
776 
777  trickframe++;
778  if (trickframe & 1)
779  {
780  gldepthmin = 0;
781  gldepthmax = 0.49999;
782  qglDepthFunc (GL_LEQUAL);
783  }
784  else
785  {
786  gldepthmin = 1;
787  gldepthmax = 0.5;
788  qglDepthFunc (GL_GEQUAL);
789  }
790  }
791  else
792  {
793  if (gl_clear->value)
794  qglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
795  else
796  qglClear (GL_DEPTH_BUFFER_BIT);
797  gldepthmin = 0;
798  gldepthmax = 1;
799  qglDepthFunc (GL_LEQUAL);
800  }
801 
802  qglDepthRange (gldepthmin, gldepthmax);
803 
804 }
805 
806 void R_Flash( void )
807 {
808  R_PolyBlend ();
809 }
810 
811 /*
812 ================
813 R_RenderView
814 
815 r_newrefdef must be set before the first call
816 ================
817 */
819 {
820  if (r_norefresh->value)
821  return;
822 
823  r_newrefdef = *fd;
824 
826  ri.Sys_Error (ERR_DROP, "R_RenderView: NULL worldmodel");
827 
828  if (r_speeds->value)
829  {
830  c_brush_polys = 0;
831  c_alias_polys = 0;
832  }
833 
834  R_PushDlights ();
835 
836  if (gl_finish->value)
837  qglFinish ();
838 
839  R_SetupFrame ();
840 
841  R_SetFrustum ();
842 
843  R_SetupGL ();
844 
845  R_MarkLeaves (); // done here so we know if we're in water
846 
847  R_DrawWorld ();
848 
850 
851  R_RenderDlights ();
852 
853  R_DrawParticles ();
854 
856 
857  R_Flash();
858 
859  if (r_speeds->value)
860  {
861  ri.Con_Printf (PRINT_ALL, "%4i wpoly %4i epoly %i tex %i lmaps\n",
862  c_brush_polys,
863  c_alias_polys,
866  }
867 }
868 
869 
870 void R_SetGL2D (void)
871 {
872  // set 2D virtual screen size
873  qglViewport (0,0, vid.width, vid.height);
874  qglMatrixMode(GL_PROJECTION);
875  qglLoadIdentity ();
876  qglOrtho (0, vid.width, vid.height, 0, -99999, 99999);
877  qglMatrixMode(GL_MODELVIEW);
878  qglLoadIdentity ();
879  qglDisable (GL_DEPTH_TEST);
880  qglDisable (GL_CULL_FACE);
881  qglDisable (GL_BLEND);
882  qglEnable (GL_ALPHA_TEST);
883  qglColor4f (1,1,1,1);
884 }
885 
886 static void GL_DrawColoredStereoLinePair( float r, float g, float b, float y )
887 {
888  qglColor3f( r, g, b );
889  qglVertex2f( 0, y );
890  qglVertex2f( vid.width, y );
891  qglColor3f( 0, 0, 0 );
892  qglVertex2f( 0, y + 1 );
893  qglVertex2f( vid.width, y + 1 );
894 }
895 
896 static void GL_DrawStereoPattern( void )
897 {
898  int i;
899 
901  return;
902 
903  if ( !gl_state.stereo_enabled )
904  return;
905 
906  R_SetGL2D();
907 
908  qglDrawBuffer( GL_BACK_LEFT );
909 
910  for ( i = 0; i < 20; i++ )
911  {
912  qglBegin( GL_LINES );
913  GL_DrawColoredStereoLinePair( 1, 0, 0, 0 );
914  GL_DrawColoredStereoLinePair( 1, 0, 0, 2 );
915  GL_DrawColoredStereoLinePair( 1, 0, 0, 4 );
916  GL_DrawColoredStereoLinePair( 1, 0, 0, 6 );
917  GL_DrawColoredStereoLinePair( 0, 1, 0, 8 );
918  GL_DrawColoredStereoLinePair( 1, 1, 0, 10);
919  GL_DrawColoredStereoLinePair( 1, 1, 0, 12);
920  GL_DrawColoredStereoLinePair( 0, 1, 0, 14);
921  qglEnd();
922 
923  GLimp_EndFrame();
924  }
925 }
926 
927 
928 /*
929 ====================
930 R_SetLightLevel
931 
932 ====================
933 */
934 void R_SetLightLevel (void)
935 {
937 
939  return;
940 
941  // save off light value for server to look at (BIG HACK!)
942 
944 
945  // pick the greatest component, which should be the same
946  // as the mono value returned by software
947  if (shadelight[0] > shadelight[1])
948  {
949  if (shadelight[0] > shadelight[2])
950  r_lightlevel->value = 150*shadelight[0];
951  else
952  r_lightlevel->value = 150*shadelight[2];
953  }
954  else
955  {
956  if (shadelight[1] > shadelight[2])
957  r_lightlevel->value = 150*shadelight[1];
958  else
959  r_lightlevel->value = 150*shadelight[2];
960  }
961 
962 }
963 
964 /*
965 @@@@@@@@@@@@@@@@@@@@@
966 R_RenderFrame
967 
968 @@@@@@@@@@@@@@@@@@@@@
969 */
971 {
972  R_RenderView( fd );
973  R_SetLightLevel ();
974  R_SetGL2D ();
975 }
976 
977 
978 void R_Register( void )
979 {
980  r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
981  r_norefresh = ri.Cvar_Get ("r_norefresh", "0", 0);
982  r_fullbright = ri.Cvar_Get ("r_fullbright", "0", 0);
983  r_drawentities = ri.Cvar_Get ("r_drawentities", "1", 0);
984  r_drawworld = ri.Cvar_Get ("r_drawworld", "1", 0);
985  r_novis = ri.Cvar_Get ("r_novis", "0", 0);
986  r_nocull = ri.Cvar_Get ("r_nocull", "0", 0);
987  r_lerpmodels = ri.Cvar_Get ("r_lerpmodels", "1", 0);
988  r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
989 
990  r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0);
991 
992  gl_nosubimage = ri.Cvar_Get( "gl_nosubimage", "0", 0 );
993  gl_allow_software = ri.Cvar_Get( "gl_allow_software", "0", 0 );
994 
995  gl_particle_min_size = ri.Cvar_Get( "gl_particle_min_size", "2", CVAR_ARCHIVE );
996  gl_particle_max_size = ri.Cvar_Get( "gl_particle_max_size", "40", CVAR_ARCHIVE );
997  gl_particle_size = ri.Cvar_Get( "gl_particle_size", "40", CVAR_ARCHIVE );
998  gl_particle_att_a = ri.Cvar_Get( "gl_particle_att_a", "0.01", CVAR_ARCHIVE );
999  gl_particle_att_b = ri.Cvar_Get( "gl_particle_att_b", "0.0", CVAR_ARCHIVE );
1000  gl_particle_att_c = ri.Cvar_Get( "gl_particle_att_c", "0.01", CVAR_ARCHIVE );
1001 
1002  gl_modulate = ri.Cvar_Get ("gl_modulate", "1", CVAR_ARCHIVE );
1003  gl_log = ri.Cvar_Get( "gl_log", "0", 0 );
1004  gl_bitdepth = ri.Cvar_Get( "gl_bitdepth", "0", 0 );
1005  gl_mode = ri.Cvar_Get( "gl_mode", "3", CVAR_ARCHIVE );
1006  gl_lightmap = ri.Cvar_Get ("gl_lightmap", "0", 0);
1007  gl_shadows = ri.Cvar_Get ("gl_shadows", "0", CVAR_ARCHIVE );
1008  gl_dynamic = ri.Cvar_Get ("gl_dynamic", "1", 0);
1009  gl_nobind = ri.Cvar_Get ("gl_nobind", "0", 0);
1010  gl_round_down = ri.Cvar_Get ("gl_round_down", "1", 0);
1011  gl_picmip = ri.Cvar_Get ("gl_picmip", "0", 0);
1012  gl_skymip = ri.Cvar_Get ("gl_skymip", "0", 0);
1013  gl_showtris = ri.Cvar_Get ("gl_showtris", "0", 0);
1014  gl_ztrick = ri.Cvar_Get ("gl_ztrick", "0", 0);
1015  gl_finish = ri.Cvar_Get ("gl_finish", "0", CVAR_ARCHIVE);
1016  gl_clear = ri.Cvar_Get ("gl_clear", "0", 0);
1017  gl_cull = ri.Cvar_Get ("gl_cull", "1", 0);
1018  gl_polyblend = ri.Cvar_Get ("gl_polyblend", "1", 0);
1019  gl_flashblend = ri.Cvar_Get ("gl_flashblend", "0", 0);
1020  gl_playermip = ri.Cvar_Get ("gl_playermip", "0", 0);
1021  gl_monolightmap = ri.Cvar_Get( "gl_monolightmap", "0", 0 );
1022 #ifdef _WIN32
1023  gl_driver = ri.Cvar_Get( "gl_driver", "opengl32", CVAR_ARCHIVE );
1024 #endif
1025 #ifdef __linux__
1026  gl_driver = ri.Cvar_Get( "gl_driver", "libGL.so", CVAR_ARCHIVE );
1027 #endif
1028  gl_texturemode = ri.Cvar_Get( "gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE );
1029  gl_texturealphamode = ri.Cvar_Get( "gl_texturealphamode", "default", CVAR_ARCHIVE );
1030  gl_texturesolidmode = ri.Cvar_Get( "gl_texturesolidmode", "default", CVAR_ARCHIVE );
1031  gl_lockpvs = ri.Cvar_Get( "gl_lockpvs", "0", 0 );
1032 
1033  gl_vertex_arrays = ri.Cvar_Get( "gl_vertex_arrays", "0", CVAR_ARCHIVE );
1034 
1035  gl_ext_swapinterval = ri.Cvar_Get( "gl_ext_swapinterval", "1", CVAR_ARCHIVE );
1036  gl_ext_palettedtexture = ri.Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE );
1037  gl_ext_multitexture = ri.Cvar_Get( "gl_ext_multitexture", "1", CVAR_ARCHIVE );
1038  gl_ext_pointparameters = ri.Cvar_Get( "gl_ext_pointparameters", "1", CVAR_ARCHIVE );
1039  gl_ext_compiled_vertex_array = ri.Cvar_Get( "gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE );
1040 
1041  gl_drawbuffer = ri.Cvar_Get( "gl_drawbuffer", "GL_BACK", 0 );
1042  gl_swapinterval = ri.Cvar_Get( "gl_swapinterval", "1", CVAR_ARCHIVE );
1043 
1044  gl_saturatelighting = ri.Cvar_Get( "gl_saturatelighting", "0", 0 );
1045 
1046  gl_3dlabs_broken = ri.Cvar_Get( "gl_3dlabs_broken", "1", CVAR_ARCHIVE );
1047 
1048  vid_fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE );
1049  vid_gamma = ri.Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE );
1050  vid_ref = ri.Cvar_Get( "vid_ref", "soft", CVAR_ARCHIVE );
1051 
1052  ri.Cmd_AddCommand( "imagelist", GL_ImageList_f );
1053  ri.Cmd_AddCommand( "screenshot", GL_ScreenShot_f );
1054  ri.Cmd_AddCommand( "modellist", Mod_Modellist_f );
1055  ri.Cmd_AddCommand( "gl_strings", GL_Strings_f );
1056 }
1057 
1058 /*
1059 ==================
1060 R_SetMode
1061 ==================
1062 */
1064 {
1065  rserr_t err;
1066  qboolean fullscreen;
1067 
1069  {
1070  ri.Con_Printf( PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n" );
1071  ri.Cvar_SetValue( "vid_fullscreen", !vid_fullscreen->value );
1072  vid_fullscreen->modified = false;
1073  }
1074 
1075  fullscreen = vid_fullscreen->value;
1076 
1077  vid_fullscreen->modified = false;
1078  gl_mode->modified = false;
1079 
1080  if ( ( err = GLimp_SetMode( &vid.width, &vid.height, gl_mode->value, fullscreen ) ) == rserr_ok )
1081  {
1083  }
1084  else
1085  {
1086  if ( err == rserr_invalid_fullscreen )
1087  {
1088  ri.Cvar_SetValue( "vid_fullscreen", 0);
1089  vid_fullscreen->modified = false;
1090  ri.Con_Printf( PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n" );
1091  if ( ( err = GLimp_SetMode( &vid.width, &vid.height, gl_mode->value, false ) ) == rserr_ok )
1092  return true;
1093  }
1094  else if ( err == rserr_invalid_mode )
1095  {
1096  ri.Cvar_SetValue( "gl_mode", gl_state.prev_mode );
1097  gl_mode->modified = false;
1098  ri.Con_Printf( PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n" );
1099  }
1100 
1101  // try setting it back to something safe
1102  if ( ( err = GLimp_SetMode( &vid.width, &vid.height, gl_state.prev_mode, false ) ) != rserr_ok )
1103  {
1104  ri.Con_Printf( PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n" );
1105  return false;
1106  }
1107  }
1108  return true;
1109 }
1110 
1111 /*
1112 ===============
1113 R_Init
1114 ===============
1115 */
1116 qboolean R_Init( void *hinstance, void *hWnd )
1117 {
1118  char renderer_buffer[1000];
1119  char vendor_buffer[1000];
1120  int err;
1121  int j;
1122  extern float r_turbsin[256];
1123 
1124  for ( j = 0; j < 256; j++ )
1125  {
1126  r_turbsin[j] *= 0.5;
1127  }
1128 
1129  ri.Con_Printf (PRINT_ALL, "ref_gl version: "REF_VERSION"\n");
1130 
1131  Draw_GetPalette ();
1132 
1133  R_Register();
1134 
1135  // initialize our QGL dynamic bindings
1136  if ( !QGL_Init( gl_driver->string ) )
1137  {
1138  QGL_Shutdown();
1139  ri.Con_Printf (PRINT_ALL, "ref_gl::R_Init() - could not load \"%s\"\n", gl_driver->string );
1140  return false;
1141  }
1142 
1143  // initialize OS-specific parts of OpenGL
1144  if ( !GLimp_Init( hinstance, hWnd ) )
1145  {
1146  QGL_Shutdown();
1147  return false;
1148  }
1149 
1150  // set our "safe" modes
1151  gl_state.prev_mode = 3;
1152 
1153  // create the window and set up the context
1154  if ( !R_SetMode () )
1155  {
1156  QGL_Shutdown();
1157  ri.Con_Printf (PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n" );
1158  return false;
1159  }
1160 
1161  ri.Vid_MenuInit();
1162 
1163  /*
1164  ** get our various GL strings
1165  */
1166  gl_config.vendor_string = qglGetString (GL_VENDOR);
1167  ri.Con_Printf (PRINT_ALL, "GL_VENDOR: %s\n", gl_config.vendor_string );
1168  gl_config.renderer_string = qglGetString (GL_RENDERER);
1169  ri.Con_Printf (PRINT_ALL, "GL_RENDERER: %s\n", gl_config.renderer_string );
1170  gl_config.version_string = qglGetString (GL_VERSION);
1171  ri.Con_Printf (PRINT_ALL, "GL_VERSION: %s\n", gl_config.version_string );
1172  gl_config.extensions_string = qglGetString (GL_EXTENSIONS);
1173  ri.Con_Printf (PRINT_ALL, "GL_EXTENSIONS: %s\n", gl_config.extensions_string );
1174 
1175  strcpy( renderer_buffer, gl_config.renderer_string );
1176  strlwr( renderer_buffer );
1177 
1178  strcpy( vendor_buffer, gl_config.vendor_string );
1179  strlwr( vendor_buffer );
1180 
1181  if ( strstr( renderer_buffer, "voodoo" ) )
1182  {
1183  if ( !strstr( renderer_buffer, "rush" ) )
1185  else
1187  }
1188  else if ( strstr( vendor_buffer, "sgi" ) )
1190  else if ( strstr( renderer_buffer, "permedia" ) )
1192  else if ( strstr( renderer_buffer, "glint" ) )
1194  else if ( strstr( renderer_buffer, "glzicd" ) )
1196  else if ( strstr( renderer_buffer, "gdi" ) )
1198  else if ( strstr( renderer_buffer, "pcx2" ) )
1200  else if ( strstr( renderer_buffer, "verite" ) )
1202  else
1204 
1205  if ( toupper( gl_monolightmap->string[1] ) != 'F' )
1206  {
1208  {
1209  ri.Cvar_Set( "gl_monolightmap", "A" );
1210  ri.Con_Printf( PRINT_ALL, "...using gl_monolightmap 'a'\n" );
1211  }
1212  else if ( gl_config.renderer & GL_RENDERER_POWERVR )
1213  {
1214  ri.Cvar_Set( "gl_monolightmap", "0" );
1215  }
1216  else
1217  {
1218  ri.Cvar_Set( "gl_monolightmap", "0" );
1219  }
1220  }
1221 
1222  // power vr can't have anything stay in the framebuffer, so
1223  // the screen needs to redraw the tiled background every frame
1225  {
1226  ri.Cvar_Set( "scr_drawall", "1" );
1227  }
1228  else
1229  {
1230  ri.Cvar_Set( "scr_drawall", "0" );
1231  }
1232 
1233 #ifdef __linux__
1234  ri.Cvar_SetValue( "gl_finish", 1 );
1235 #endif
1236 
1237  // MCD has buffering issues
1239  {
1240  ri.Cvar_SetValue( "gl_finish", 1 );
1241  }
1242 
1244  {
1245  if ( gl_3dlabs_broken->value )
1246  gl_config.allow_cds = false;
1247  else
1248  gl_config.allow_cds = true;
1249  }
1250  else
1251  {
1252  gl_config.allow_cds = true;
1253  }
1254 
1255  if ( gl_config.allow_cds )
1256  ri.Con_Printf( PRINT_ALL, "...allowing CDS\n" );
1257  else
1258  ri.Con_Printf( PRINT_ALL, "...disabling CDS\n" );
1259 
1260  /*
1261  ** grab extensions
1262  */
1263  if ( strstr( gl_config.extensions_string, "GL_EXT_compiled_vertex_array" ) ||
1264  strstr( gl_config.extensions_string, "GL_SGI_compiled_vertex_array" ) )
1265  {
1266  ri.Con_Printf( PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n" );
1267  qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" );
1268  qglUnlockArraysEXT = ( void * ) qwglGetProcAddress( "glUnlockArraysEXT" );
1269  }
1270  else
1271  {
1272  ri.Con_Printf( PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n" );
1273  }
1274 
1275 #ifdef _WIN32
1276  if ( strstr( gl_config.extensions_string, "WGL_EXT_swap_control" ) )
1277  {
1278  qwglSwapIntervalEXT = ( BOOL (WINAPI *)(int)) qwglGetProcAddress( "wglSwapIntervalEXT" );
1279  ri.Con_Printf( PRINT_ALL, "...enabling WGL_EXT_swap_control\n" );
1280  }
1281  else
1282  {
1283  ri.Con_Printf( PRINT_ALL, "...WGL_EXT_swap_control not found\n" );
1284  }
1285 #endif
1286 
1287  if ( strstr( gl_config.extensions_string, "GL_EXT_point_parameters" ) )
1288  {
1290  {
1291  qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" );
1292  qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" );
1293  ri.Con_Printf( PRINT_ALL, "...using GL_EXT_point_parameters\n" );
1294  }
1295  else
1296  {
1297  ri.Con_Printf( PRINT_ALL, "...ignoring GL_EXT_point_parameters\n" );
1298  }
1299  }
1300  else
1301  {
1302  ri.Con_Printf( PRINT_ALL, "...GL_EXT_point_parameters not found\n" );
1303  }
1304 
1305 #ifdef __linux__
1306  if ( strstr( gl_config.extensions_string, "3DFX_set_global_palette" ))
1307  {
1309  {
1310  ri.Con_Printf( PRINT_ALL, "...using 3DFX_set_global_palette\n" );
1311  qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress( "gl3DfxSetPaletteEXT" );
1312  qglColorTableEXT = Fake_glColorTableEXT;
1313  }
1314  else
1315  {
1316  ri.Con_Printf( PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" );
1317  }
1318  }
1319  else
1320  {
1321  ri.Con_Printf( PRINT_ALL, "...3DFX_set_global_palette not found\n" );
1322  }
1323 #endif
1324 
1325  if ( !qglColorTableEXT &&
1326  strstr( gl_config.extensions_string, "GL_EXT_paletted_texture" ) &&
1327  strstr( gl_config.extensions_string, "GL_EXT_shared_texture_palette" ) )
1328  {
1330  {
1331  ri.Con_Printf( PRINT_ALL, "...using GL_EXT_shared_texture_palette\n" );
1332  qglColorTableEXT = ( void ( APIENTRY * ) ( GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid * ) ) qwglGetProcAddress( "glColorTableEXT" );
1333  }
1334  else
1335  {
1336  ri.Con_Printf( PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n" );
1337  }
1338  }
1339  else
1340  {
1341  ri.Con_Printf( PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n" );
1342  }
1343 
1344  if ( strstr( gl_config.extensions_string, "GL_ARB_multitexture" ) )
1345  {
1346  if ( gl_ext_multitexture->value )
1347  {
1348  ri.Con_Printf( PRINT_ALL, "...using GL_ARB_multitexture\n" );
1349  qglMTexCoord2fSGIS = ( void * ) qwglGetProcAddress( "glMultiTexCoord2fARB" );
1350  qglActiveTextureARB = ( void * ) qwglGetProcAddress( "glActiveTextureARB" );
1351  qglClientActiveTextureARB = ( void * ) qwglGetProcAddress( "glClientActiveTextureARB" );
1354  }
1355  else
1356  {
1357  ri.Con_Printf( PRINT_ALL, "...ignoring GL_ARB_multitexture\n" );
1358  }
1359  }
1360  else
1361  {
1362  ri.Con_Printf( PRINT_ALL, "...GL_ARB_multitexture not found\n" );
1363  }
1364 
1365  if ( strstr( gl_config.extensions_string, "GL_SGIS_multitexture" ) )
1366  {
1367  if ( qglActiveTextureARB )
1368  {
1369  ri.Con_Printf( PRINT_ALL, "...GL_SGIS_multitexture deprecated in favor of ARB_multitexture\n" );
1370  }
1371  else if ( gl_ext_multitexture->value )
1372  {
1373  ri.Con_Printf( PRINT_ALL, "...using GL_SGIS_multitexture\n" );
1374  qglMTexCoord2fSGIS = ( void * ) qwglGetProcAddress( "glMTexCoord2fSGIS" );
1375  qglSelectTextureSGIS = ( void * ) qwglGetProcAddress( "glSelectTextureSGIS" );
1378  }
1379  else
1380  {
1381  ri.Con_Printf( PRINT_ALL, "...ignoring GL_SGIS_multitexture\n" );
1382  }
1383  }
1384  else
1385  {
1386  ri.Con_Printf( PRINT_ALL, "...GL_SGIS_multitexture not found\n" );
1387  }
1388 
1390 
1391  /*
1392  ** draw our stereo patterns
1393  */
1394 #if 0 // commented out until H3D pays us the money they owe us
1396 #endif
1397 
1398  GL_InitImages ();
1399  Mod_Init ();
1401  Draw_InitLocal ();
1402 
1403  err = qglGetError();
1404  if ( err != GL_NO_ERROR )
1405  ri.Con_Printf (PRINT_ALL, "glGetError() = 0x%x\n", err);
1406 
1407  return true;
1408 }
1409 
1410 /*
1411 ===============
1412 R_Shutdown
1413 ===============
1414 */
1415 void R_Shutdown (void)
1416 {
1417  ri.Cmd_RemoveCommand ("modellist");
1418  ri.Cmd_RemoveCommand ("screenshot");
1419  ri.Cmd_RemoveCommand ("imagelist");
1420  ri.Cmd_RemoveCommand ("gl_strings");
1421 
1422  Mod_FreeAll ();
1423 
1424  GL_ShutdownImages ();
1425 
1426  /*
1427  ** shut down OS specific OpenGL stuff like contexts, etc.
1428  */
1429  GLimp_Shutdown();
1430 
1431  /*
1432  ** shutdown our QGL subsystem
1433  */
1434  QGL_Shutdown();
1435 }
1436 
1437 
1438 
1439 /*
1440 @@@@@@@@@@@@@@@@@@@@@
1441 R_BeginFrame
1442 @@@@@@@@@@@@@@@@@@@@@
1443 */
1444 void R_BeginFrame( float camera_separation )
1445 {
1446 
1447  gl_state.camera_separation = camera_separation;
1448 
1449  /*
1450  ** change modes if necessary
1451  */
1453  { // FIXME: only restart if CDS is required
1454  cvar_t *ref;
1455 
1456  ref = ri.Cvar_Get ("vid_ref", "gl", 0);
1457  ref->modified = true;
1458  }
1459 
1460  if ( gl_log->modified )
1461  {
1463  gl_log->modified = false;
1464  }
1465 
1466  if ( gl_log->value )
1467  {
1469  }
1470 
1471  /*
1472  ** update 3Dfx gamma -- it is expected that a user will do a vid_restart
1473  ** after tweaking this value
1474  */
1475  if ( vid_gamma->modified )
1476  {
1477  vid_gamma->modified = false;
1478 
1480  {
1481  char envbuffer[1024];
1482  float g;
1483 
1484  g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F;
1485  Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g );
1486  putenv( envbuffer );
1487  Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g );
1488  putenv( envbuffer );
1489  }
1490  }
1491 
1492  GLimp_BeginFrame( camera_separation );
1493 
1494  /*
1495  ** go into 2D mode
1496  */
1497  qglViewport (0,0, vid.width, vid.height);
1498  qglMatrixMode(GL_PROJECTION);
1499  qglLoadIdentity ();
1500  qglOrtho (0, vid.width, vid.height, 0, -99999, 99999);
1501  qglMatrixMode(GL_MODELVIEW);
1502  qglLoadIdentity ();
1503  qglDisable (GL_DEPTH_TEST);
1504  qglDisable (GL_CULL_FACE);
1505  qglDisable (GL_BLEND);
1506  qglEnable (GL_ALPHA_TEST);
1507  qglColor4f (1,1,1,1);
1508 
1509  /*
1510  ** draw buffer stuff
1511  */
1512  if ( gl_drawbuffer->modified )
1513  {
1514  gl_drawbuffer->modified = false;
1515 
1517  {
1518  if ( Q_stricmp( gl_drawbuffer->string, "GL_FRONT" ) == 0 )
1519  qglDrawBuffer( GL_FRONT );
1520  else
1521  qglDrawBuffer( GL_BACK );
1522  }
1523  }
1524 
1525  /*
1526  ** texturemode stuff
1527  */
1528  if ( gl_texturemode->modified )
1529  {
1531  gl_texturemode->modified = false;
1532  }
1533 
1535  {
1537  gl_texturealphamode->modified = false;
1538  }
1539 
1541  {
1543  gl_texturesolidmode->modified = false;
1544  }
1545 
1546  /*
1547  ** swapinterval stuff
1548  */
1550 
1551  //
1552  // clear screen if desired
1553  //
1554  R_Clear ();
1555 }
1556 
1557 /*
1558 =============
1559 R_EndWorldRenderpass
1560 =============
1561 */
1563 {
1564  // old OpenGL renderer has only one pass
1565 }
1566 
1567 /*
1568 =============
1569 R_SetPalette
1570 =============
1571 */
1572 unsigned r_rawpalette[256];
1573 
1574 void R_SetPalette ( const unsigned char *palette)
1575 {
1576  int i;
1577 
1578  byte *rp = ( byte * ) r_rawpalette;
1579 
1580  if ( palette )
1581  {
1582  for ( i = 0; i < 256; i++ )
1583  {
1584  rp[i*4+0] = palette[i*3+0];
1585  rp[i*4+1] = palette[i*3+1];
1586  rp[i*4+2] = palette[i*3+2];
1587  rp[i*4+3] = 0xff;
1588  }
1589  }
1590  else
1591  {
1592  for ( i = 0; i < 256; i++ )
1593  {
1594  rp[i*4+0] = d_8to24table[i] & 0xff;
1595  rp[i*4+1] = ( d_8to24table[i] >> 8 ) & 0xff;
1596  rp[i*4+2] = ( d_8to24table[i] >> 16 ) & 0xff;
1597  rp[i*4+3] = 0xff;
1598  }
1599  }
1601 
1602  qglClearColor (0,0,0,0);
1603  qglClear (GL_COLOR_BUFFER_BIT);
1604  qglClearColor (1,0, 0.5 , 0.5);
1605 }
1606 
1607 /*
1608 ** R_DrawBeam
1609 */
1611 {
1612 #define NUM_BEAM_SEGS 6
1613 
1614  int i;
1615  float r, g, b;
1616 
1617  vec3_t perpvec;
1618  vec3_t direction, normalized_direction;
1619  vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
1620  vec3_t oldorigin, origin;
1621 
1622  oldorigin[0] = e->oldorigin[0];
1623  oldorigin[1] = e->oldorigin[1];
1624  oldorigin[2] = e->oldorigin[2];
1625 
1626  origin[0] = e->origin[0];
1627  origin[1] = e->origin[1];
1628  origin[2] = e->origin[2];
1629 
1630  normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
1631  normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
1632  normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
1633 
1634  if ( VectorNormalize( normalized_direction ) == 0 )
1635  return;
1636 
1637  PerpendicularVector( perpvec, normalized_direction );
1638  VectorScale( perpvec, e->frame / 2, perpvec );
1639 
1640  for ( i = 0; i < 6; i++ )
1641  {
1642  RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );
1643  VectorAdd( start_points[i], origin, start_points[i] );
1644  VectorAdd( start_points[i], direction, end_points[i] );
1645  }
1646 
1647  qglDisable( GL_TEXTURE_2D );
1648  qglEnable( GL_BLEND );
1649  qglDepthMask( GL_FALSE );
1650 
1651  r = ( d_8to24table[e->skinnum & 0xFF] ) & 0xFF;
1652  g = ( d_8to24table[e->skinnum & 0xFF] >> 8 ) & 0xFF;
1653  b = ( d_8to24table[e->skinnum & 0xFF] >> 16 ) & 0xFF;
1654 
1655  r *= 1/255.0F;
1656  g *= 1/255.0F;
1657  b *= 1/255.0F;
1658 
1659  qglColor4f( r, g, b, e->alpha );
1660 
1661  qglBegin( GL_TRIANGLE_STRIP );
1662  for ( i = 0; i < NUM_BEAM_SEGS; i++ )
1663  {
1664  qglVertex3fv( start_points[i] );
1665  qglVertex3fv( end_points[i] );
1666  qglVertex3fv( start_points[(i+1)%NUM_BEAM_SEGS] );
1667  qglVertex3fv( end_points[(i+1)%NUM_BEAM_SEGS] );
1668  }
1669  qglEnd();
1670 
1671  qglEnable( GL_TEXTURE_2D );
1672  qglDisable( GL_BLEND );
1673  qglDepthMask( GL_TRUE );
1674 }
1675 
1676 //===================================================================
1677 
1678 
1679 void R_BeginRegistration (char *map);
1680 struct model_s *R_RegisterModel (char *name);
1681 struct image_s *R_RegisterSkin (char *name);
1682 void R_SetSky (char *name, float rotate, vec3_t axis);
1683 void R_EndRegistration (void);
1684 
1685 void R_RenderFrame (refdef_t *fd);
1686 
1687 struct image_s *Draw_FindPic (char *name);
1688 
1689 void Draw_Pic (int x, int y, char *name);
1690 void Draw_Char (int x, int y, int c);
1691 void Draw_TileClear (int x, int y, int w, int h, char *name);
1692 void Draw_Fill (int x, int y, int w, int h, int c);
1693 void Draw_FadeScreen (void);
1694 
1695 /*
1696 @@@@@@@@@@@@@@@@@@@@@
1697 GetRefAPI
1698 
1699 @@@@@@@@@@@@@@@@@@@@@
1700 */
1702 {
1703  refexport_t re;
1704 
1705  ri = rimp;
1706 
1708 
1713  re.SetSky = R_SetSky;
1715 
1717 
1719  re.DrawPic = Draw_Pic;
1721  re.DrawChar = Draw_Char;
1723  re.DrawFill = Draw_Fill;
1725 
1727 
1728  re.Init = R_Init;
1730 
1735 
1737 
1738  Swap_Init ();
1739 
1740  return re;
1741 }
1742 
1743 
1744 #ifndef REF_HARD_LINKED
1745 // this is only here so the functions in q_shared.c and q_shwin.c can link
1746 void Sys_Error (char *error, ...)
1747 {
1748  va_list argptr;
1749  char text[1024];
1750 
1751  va_start (argptr, error);
1752  vsnprintf (text, 1024, error, argptr);
1753  va_end (argptr);
1754 
1755  ri.Sys_Error (ERR_FATAL, "%s", text);
1756 }
1757 
1758 void Com_Printf (char *fmt, ...)
1759 {
1760  va_list argptr;
1761  char text[1024];
1762 
1763  va_start (argptr, fmt);
1764  vsnprintf (text, 1024, fmt, argptr);
1765  va_end (argptr);
1766 
1767  ri.Con_Printf (PRINT_ALL, "%s", text);
1768 }
1769 
1770 #endif
GL_RENDERER_VOODOO
#define GL_RENDERER_VOODOO
Definition: gl_local.h:356
RF_TRANSLUCENT
#define RF_TRANSLUCENT
Definition: q_shared.h:604
Draw_Char
void Draw_Char(int x, int y, int c)
Definition: r_draw.c:242
gl_particle_min_size
cvar_t * gl_particle_min_size
Definition: gl_rmain.c:96
GLimp_Shutdown
void GLimp_Shutdown(void)
Definition: glw_imp.c:276
refexport_t::RegisterSkin
struct image_s *(* RegisterSkin)(char *name)
Definition: ref.h:159
GL_RENDERER_INTERGRAPH
#define GL_RENDERER_INTERGRAPH
Definition: gl_local.h:375
cplane_s::normal
vec3_t normal
Definition: q_shared.h:415
refdef_t::vieworg
float vieworg[3]
Definition: ref.h:106
refimport_t::Cmd_RemoveCommand
void(* Cmd_RemoveCommand)(char *name)
Definition: ref.h:197
rserr_t
rserr_t
Definition: r_local.h:103
y2
GLdouble GLdouble GLdouble y2
Definition: qgl_win.c:301
R_Shutdown
void R_Shutdown(void)
Definition: gl_rmain.c:1415
cplane_s::type
byte type
Definition: q_shared.h:417
gl_particle_att_a
cvar_t * gl_particle_att_a
Definition: gl_rmain.c:99
R_BeginFrame
void R_BeginFrame(float camera_separation)
Definition: gl_rmain.c:1444
c_brush_polys
int c_brush_polys
Definition: gl_rmain.c:55
glstate_t::stereo_enabled
qboolean stereo_enabled
Definition: gl_local.h:422
gl_lockpvs
cvar_t * gl_lockpvs
Definition: gl_rmain.c:136
entity_s::origin
float origin[3]
Definition: ref.h:57
entity_s::model
struct model_s * model
Definition: ref.h:51
gl_saturatelighting
cvar_t * gl_saturatelighting
Definition: gl_rmain.c:131
r_particletexture
image_t * r_particletexture
Definition: gl_rmain.c:45
refdef_t
Definition: ref.h:102
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
r_novis
cvar_t * r_novis
Definition: gl_rmain.c:84
r_visframecount
int r_visframecount
Definition: gl_rmain.c:52
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:163
gl_ext_swapinterval
cvar_t * gl_ext_swapinterval
Definition: gl_rmain.c:103
GL_TEXTURE1_SGIS
#define GL_TEXTURE1_SGIS
Definition: qgl.h:480
R_RenderFrame
void R_RenderFrame(refdef_t *fd)
Definition: gl_rmain.c:970
Swap_Init
void Swap_Init(void)
Definition: q_shared.c:1011
c_visible_lightmaps
int c_visible_lightmaps
Definition: gl_rsurf.c:40
R_SetupFrame
void R_SetupFrame(void)
Definition: gl_rmain.c:618
Draw_Pic
void Draw_Pic(int x, int y, char *name)
Definition: r_draw.c:438
BOX_ON_PLANE_SIDE
#define BOX_ON_PLANE_SIDE(emins, emaxs, p)
Definition: q_shared.h:197
R_PushDlights
void R_PushDlights(model_t *model)
Definition: r_light.c:94
R_DrawBeam
void R_DrawBeam(entity_t *e)
Definition: gl_rmain.c:1610
Draw_StretchRaw
void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
Definition: r_draw.c:423
GL_TextureAlphaMode
void GL_TextureAlphaMode(char *string)
Definition: gl_image.c:255
gl_monolightmap
cvar_t * gl_monolightmap
Definition: gl_rmain.c:117
glconfig_t::extensions_string
const char * extensions_string
Definition: gl_local.h:402
R_Register
void R_Register(void)
Definition: gl_rmain.c:978
r_lefthand
cvar_t * r_lefthand
Definition: gl_rmain.c:87
refexport_t::DrawStretchRaw
void(* DrawStretchRaw)(int x, int y, int w, int h, int cols, int rows, byte *data)
Definition: ref.h:175
cvar_s::modified
qboolean modified
Definition: q_shared.h:330
zNear
GLdouble GLdouble GLdouble GLdouble zNear
Definition: qgl_win.c:159
gl_texture1
int gl_texture1
Definition: gl_rmain.c:35
cplane_s::signbits
byte signbits
Definition: q_shared.h:418
gl_drawbuffer
cvar_t * gl_drawbuffer
Definition: gl_rmain.c:111
dsprframe_t::height
int height
Definition: qfiles.h:176
glconfig_t
Definition: gl_local.h:396
GL_TextureMode
void GL_TextureMode(char *string)
Definition: gl_image.c:218
qglGetString
const GLubyte *APIENTRY * qglGetString(GLenum name)
gl_finish
cvar_t * gl_finish
Definition: gl_rmain.c:125
refexport_t::RegisterPic
struct image_s *(* RegisterPic)(char *name)
Definition: ref.h:160
refexport_t::DrawFill
void(* DrawFill)(int x, int y, int w, int h, int c)
Definition: ref.h:171
Mod_PointInLeaf
mleaf_t * Mod_PointInLeaf(vec3_t p, model_t *model)
Definition: r_model.c:188
gl_showtris
cvar_t * gl_showtris
Definition: gl_rmain.c:123
R_LightPoint
void R_LightPoint(vec3_t p, vec3_t color)
Definition: r_light.c:226
glstate_t::prev_mode
int prev_mode
Definition: gl_local.h:412
x2
GLdouble GLdouble x2
Definition: qgl_win.c:301
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:216
cvar_s::string
char * string
Definition: q_shared.h:327
VectorScale
void VectorScale(vec3_t in, vec_t scale, vec3_t out)
Definition: q_shared.c:782
qboolean
qboolean
Definition: q_shared.h:63
x
GLint GLenum GLint x
Definition: qgl_win.c:116
entity_s::skinnum
int skinnum
Definition: ref.h:70
i
int i
Definition: q_shared.c:305
gl_state
glstate_t gl_state
Definition: gl_rmain.c:42
Sys_Error
void Sys_Error(char *error,...)
Definition: gl_rmain.c:1746
API_VERSION
#define API_VERSION
Definition: ref.h:128
refdef_t::y
int y
Definition: ref.h:104
glstate_t::camera_separation
float camera_separation
Definition: gl_local.h:421
c_alias_polys
int c_alias_polys
Definition: gl_rmain.c:55
gl_vertex_arrays
cvar_t * gl_vertex_arrays
Definition: gl_rmain.c:94
GetRefAPI
refexport_t GetRefAPI(refimport_t rimp)
Definition: gl_rmain.c:1701
gl_ztrick
cvar_t * gl_ztrick
Definition: gl_rmain.c:124
GL_RENDERER_POWERVR
#define GL_RENDERER_POWERVR
Definition: gl_local.h:365
GLimp_AppActivate
void GLimp_AppActivate(qboolean active)
Definition: glw_imp.c:578
model_s
Definition: r_model.h:171
Draw_FindPic
struct image_s * Draw_FindPic(char *name)
Definition: r_draw.c:37
r_oldviewcluster
int r_oldviewcluster
Definition: gl_rmain.c:77
R_DrawSpriteModel
void R_DrawSpriteModel(entity_t *e)
Definition: gl_rmain.c:189
GL_RENDERER_MCD
#define GL_RENDERER_MCD
Definition: gl_local.h:393
gl_ext_palettedtexture
cvar_t * gl_ext_palettedtexture
Definition: gl_rmain.c:104
refimport_t::Cvar_Set
cvar_t *(* Cvar_Set)(char *name, char *value)
Definition: ref.h:217
refdef_t::rdflags
int rdflags
Definition: ref.h:110
gl_texture0
int gl_texture0
Definition: gl_rmain.c:35
v_blend
float v_blend[4]
Definition: gl_rmain.c:57
CONTENTS_SOLID
#define CONTENTS_SOLID
Definition: qfiles.h:333
R_BeginRegistration
void R_BeginRegistration(char *map)
Definition: r_model.c:1213
entity_s::flags
int flags
Definition: ref.h:76
GL_RENDERER_RENDITION
#define GL_RENDERER_RENDITION
Definition: gl_local.h:385
GLfloat
GLfloat
Definition: qgl_win.c:410
M_PI
#define M_PI
Definition: q_shared.h:142
refexport_t::AppActivate
void(* AppActivate)(qboolean activate)
Definition: ref.h:185
mleaf_s::contents
int contents
Definition: r_model.h:146
viddef_t
Definition: vid.h:27
gl_texturemode
cvar_t * gl_texturemode
Definition: gl_rmain.c:133
cvar_s
Definition: q_shared.h:324
mod_brush
@ mod_brush
Definition: r_model.h:169
gl_shadows
cvar_t * gl_shadows
Definition: gl_rmain.c:114
gl_skymip
cvar_t * gl_skymip
Definition: gl_rmain.c:122
mleaf_s
Definition: r_model.h:143
model_s::extradata
void * extradata
Definition: r_model.h:235
GL_TextureSolidMode
void GL_TextureSolidMode(char *string)
Definition: gl_image.c:279
GL_ImageList_f
void GL_ImageList_f(void)
Definition: gl_image.c:303
GLimp_EnableLogging
void GLimp_EnableLogging(qboolean enable)
Definition: qgl_win.c:3427
refexport_t::EndRegistration
void(* EndRegistration)(void)
Definition: ref.h:162
r_worldmodel
model_t * r_worldmodel
Definition: gl_rmain.c:37
refexport_t::EndFrame
void(* EndFrame)(void)
Definition: ref.h:182
j
GLint j
Definition: qgl_win.c:150
GLenum
GLenum
Definition: qgl_win.c:408
R_EndRegistration
void R_EndRegistration(void)
Definition: r_model.c:1282
NUM_BEAM_SEGS
#define NUM_BEAM_SEGS
r_norefresh
cvar_t * r_norefresh
Definition: gl_rmain.c:79
Mod_FreeAll
void Mod_FreeAll(void)
Definition: r_model.c:1324
dsprite_t
Definition: qfiles.h:181
gl_3dlabs_broken
cvar_t * gl_3dlabs_broken
Definition: gl_rmain.c:138
GLimp_LogNewFrame
void GLimp_LogNewFrame(void)
Definition: qgl_win.c:4127
GL_RENDERER_GLINT_MX
#define GL_RENDERER_GLINT_MX
Definition: gl_local.h:368
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: q_shared.c:93
gl_bitdepth
cvar_t * gl_bitdepth
Definition: gl_rmain.c:110
RF_BEAM
#define RF_BEAM
Definition: q_shared.h:606
ref
GLclampf ref
Definition: qgl_win.c:64
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
R_SetFrustum
void R_SetFrustum(void)
Definition: gl_rmain.c:571
refexport_t::DrawFadeScreen
void(* DrawFadeScreen)(void)
Definition: ref.h:172
gl_polyblend
cvar_t * gl_polyblend
Definition: gl_rmain.c:128
gl_allow_software
cvar_t * gl_allow_software
Definition: gl_rmain.c:92
RDF_NOWORLDMODEL
#define RDF_NOWORLDMODEL
Definition: q_shared.h:622
R_SetPalette
void R_SetPalette(const unsigned char *palette)
Definition: gl_rmain.c:1574
GLimp_BeginFrame
void GLimp_BeginFrame(float camera_separation)
Definition: glw_imp.c:528
gl_picmip
cvar_t * gl_picmip
Definition: gl_rmain.c:121
Draw_InitLocal
void Draw_InitLocal(void)
Definition: r_draw.c:222
gl_cull
cvar_t * gl_cull
Definition: gl_rmain.c:127
entity_s::alpha
float alpha
Definition: ref.h:73
r
GLdouble GLdouble r
Definition: qgl_win.c:336
gl_clear
cvar_t * gl_clear
Definition: gl_rmain.c:126
viddef_t::width
unsigned width
Definition: vid.h:29
refimport_t
Definition: ref.h:192
model_s::type
modtype_t type
Definition: r_model.h:177
refimport_t::Cmd_AddCommand
void(* Cmd_AddCommand)(char *name, void(*cmd)(void))
Definition: ref.h:196
R_SetMode
qboolean R_SetMode(void)
Definition: gl_rmain.c:1063
Draw_FadeScreen
void Draw_FadeScreen(void)
Definition: r_draw.c:620
BOOL
CONST COLORREF COLORREF BOOL
Definition: qgl_win.c:60
particle_t::alpha
float alpha
Definition: ref.h:93
rserr_invalid_mode
@ rserr_invalid_mode
Definition: r_local.h:108
PerpendicularVector
void PerpendicularVector(vec3_t dst, const vec3_t src)
Definition: q_shared.c:152
gl_texturealphamode
cvar_t * gl_texturealphamode
Definition: gl_rmain.c:134
GLuint
GLuint(APIENTRY *qglGenLists)(GLsizei range)
GL_RENDERER_PCX2
#define GL_RENDERER_PCX2
Definition: gl_local.h:363
mleaf_s::cluster
int cluster
Definition: r_model.h:154
image_s::texnum
int texnum
Definition: gl_local.h:95
gl_texturesolidmode
cvar_t * gl_texturesolidmode
Definition: gl_rmain.c:135
r_world_matrix
float r_world_matrix[16]
Definition: gl_rmain.c:69
ri
refimport_t ri
Definition: gl_rmain.c:33
Com_Printf
void Com_Printf(char *fmt,...)
Definition: gl_rmain.c:1758
r_origin
vec3_t r_origin
Definition: gl_rmain.c:67
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:194
glstate_t
Definition: gl_local.h:407
GL_Bind
void GL_Bind(int texnum)
Definition: gl_image.c:137
R_SetupGL
void R_SetupGL(void)
Definition: gl_rmain.c:705
GL_RENDERER_VOODOO_RUSH
#define GL_RENDERER_VOODOO_RUSH
Definition: gl_local.h:358
R_RegisterSkin
struct image_s * R_RegisterSkin(char *name)
Definition: r_image.c:550
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:316
viddef_t::height
unsigned height
Definition: vid.h:29
refexport_t
Definition: ref.h:133
GL_TEXTURE1_ARB
#define GL_TEXTURE1_ARB
Definition: qgl.h:482
r_base_world_matrix
float r_base_world_matrix[16]
Definition: gl_rmain.c:70
gl_swapinterval
cvar_t * gl_swapinterval
Definition: gl_rmain.c:132
cvar_s::value
float value
Definition: q_shared.h:331
cplane_s::dist
float dist
Definition: q_shared.h:416
GL_RENDERER_PERMEDIA2
#define GL_RENDERER_PERMEDIA2
Definition: gl_local.h:367
gl_mode
cvar_t * gl_mode
Definition: gl_rmain.c:115
GLimp_SetMode
rserr_t GLimp_SetMode(int *pwidth, int *pheight, int mode, qboolean fullscreen)
Definition: glw_imp.c:185
gl_driver
cvar_t * gl_driver
Definition: gl_rmain.c:112
error
static int error(vorb *f, enum STBVorbisError e)
Definition: stb_vorbis.c:865
Mod_Init
void Mod_Init(void)
Definition: r_model.c:78
refdef_t::blend
float blend[4]
Definition: ref.h:108
r_oldviewcluster2
int r_oldviewcluster2
Definition: gl_rmain.c:77
VectorNormalize
vec_t VectorNormalize(vec3_t v)
Definition: q_shared.c:681
F
#define F(X, Y, Z)
Definition: md4.c:13
refexport_t::DrawGetPicSize
void(* DrawGetPicSize)(int *w, int *h, char *name)
Definition: ref.h:166
refexport_t::CinematicSetPalette
void(* CinematicSetPalette)(const unsigned char *palette)
Definition: ref.h:180
GL_TEXTURE0_SGIS
#define GL_TEXTURE0_SGIS
Definition: qgl.h:479
GL_RENDERER_SGI
#define GL_RENDERER_SGI
Definition: gl_local.h:391
gl_modulate
cvar_t * gl_modulate
Definition: gl_rmain.c:118
GL_SetTexturePalette
void GL_SetTexturePalette(unsigned palette[256])
Definition: gl_image.c:48
R_RotateForEntity
void R_RotateForEntity(entity_t *e)
Definition: gl_rmain.c:165
particle_t
Definition: ref.h:89
gl_playermip
cvar_t * gl_playermip
Definition: gl_rmain.c:130
gl_nosubimage
cvar_t * gl_nosubimage
Definition: gl_rmain.c:91
refexport_t::DrawPic
void(* DrawPic)(int x, int y, char *name)
Definition: ref.h:167
gl_particle_max_size
cvar_t * gl_particle_max_size
Definition: gl_rmain.c:97
alpha
GLfloat GLfloat GLfloat alpha
Definition: qgl_win.c:74
refdef_t::num_particles
int num_particles
Definition: ref.h:122
refdef_t::height
int height
Definition: ref.h:104
refexport_t::RegisterModel
struct model_s *(* RegisterModel)(char *name)
Definition: ref.h:158
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
MYgluPerspective
void MYgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
Definition: gl_rmain.c:682
dsprite_t::frames
dsprframe_t frames[1]
Definition: qfiles.h:185
Q_stricmp
int Q_stricmp(char *s1, char *s2)
Definition: q_shared.c:1180
r_drawentities
cvar_t * r_drawentities
Definition: gl_rmain.c:80
dsprframe_t::width
int width
Definition: qfiles.h:176
SignbitsForPlane
int SignbitsForPlane(cplane_t *out)
Definition: gl_rmain.c:555
particle_t::origin
vec3_t origin
Definition: ref.h:91
name
cvar_t * name
Definition: cl_main.c:79
REF_VERSION
#define REF_VERSION
Definition: r_local.h:36
r_lerpmodels
cvar_t * r_lerpmodels
Definition: gl_rmain.c:86
R_DrawWorld
void R_DrawWorld(void)
Definition: gl_rsurf.c:1197
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
Draw_GetPalette
void Draw_GetPalette(void)
Definition: r_main.c:1423
refexport_t::BeginRegistration
void(* BeginRegistration)(char *map)
Definition: ref.h:157
mod_sprite
@ mod_sprite
Definition: r_model.h:169
GL_RENDERER_OTHER
#define GL_RENDERER_OTHER
Definition: gl_local.h:394
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:164
glconfig_t::renderer
int renderer
Definition: gl_local.h:398
s
static fixed16_t s
Definition: r_scan.c:30
PLANE_ANYZ
#define PLANE_ANYZ
Definition: qfiles.h:314
glconfig_t::renderer_string
const char * renderer_string
Definition: gl_local.h:399
y
GLint y
Definition: qgl_win.c:115
gldepthmax
float gldepthmax
Definition: gl_rmain.c:39
re
refexport_t re
Definition: vid_dll.c:32
R_PolyBlend
void R_PolyBlend(void)
Definition: gl_rmain.c:518
R_Flash
void R_Flash(void)
Definition: gl_rmain.c:806
R_Init
qboolean R_Init(void *hinstance, void *hWnd)
Definition: gl_rmain.c:1116
r_drawworld
cvar_t * r_drawworld
Definition: gl_rmain.c:81
r_nocull
cvar_t * r_nocull
Definition: gl_rmain.c:85
GL_RENDERER_REALIZM
#define GL_RENDERER_REALIZM
Definition: gl_local.h:373
entity_s::frame
int frame
Definition: ref.h:58
r_viewcluster2
int r_viewcluster2
Definition: gl_rmain.c:77
zFar
GLclampd zFar
Definition: qgl_win.c:125
refexport_t::BeginFrame
void(* BeginFrame)(float camera_separation)
Definition: ref.h:181
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
currentmodel
model_t * currentmodel
Definition: gl_rmain.c:48
GLimp_Init
qboolean GLimp_Init(void *hinstance, void *wndproc)
Definition: glw_imp.c:321
r_turbsin
float r_turbsin[]
Definition: gl_warp.c:198
R_SetSky
void R_SetSky(char *name, float rotate, vec3_t axis)
Definition: r_main.c:1401
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
GL_TEXTURE0_ARB
#define GL_TEXTURE0_ARB
Definition: qgl.h:481
refexport_t::EndWorldRenderpass
void(* EndWorldRenderpass)(void)
Definition: ref.h:183
refdef_t::particles
particle_t * particles
Definition: ref.h:123
d_8to24table
unsigned d_8to24table[256]
Definition: r_main.c:27
R_DrawNullModel
void R_DrawNullModel(void)
Definition: gl_rmain.c:286
R_RenderDlights
void R_RenderDlights(void)
Definition: gl_light.c:77
refdef_t::num_entities
int num_entities
Definition: ref.h:116
r_viewcluster
int r_viewcluster
Definition: gl_rmain.c:77
refexport_t::SetSky
void(* SetSky)(char *name, float rotate, vec3_t axis)
Definition: ref.h:161
GL_DrawColoredStereoLinePair
static void GL_DrawColoredStereoLinePair(float r, float g, float b, float y)
Definition: gl_rmain.c:886
up
static vec3_t up
Definition: p_view.c:29
r_newrefdef
refdef_t r_newrefdef
Definition: gl_rmain.c:75
APIENTRY
#define APIENTRY
Definition: qgl.h:42
dsprite_t::numframes
int numframes
Definition: qfiles.h:184
R_DrawBrushModel
void R_DrawBrushModel(entity_t *e)
Definition: gl_rsurf.c:957
vid_ref
cvar_t * vid_ref
Definition: gl_rmain.c:142
gldepthmin
float gldepthmin
Definition: gl_rmain.c:39
rserr_ok
@ rserr_ok
Definition: r_local.h:105
refimport_t::Vid_MenuInit
void(* Vid_MenuInit)(void)
Definition: ref.h:221
vid_gamma
cvar_t * vid_gamma
Definition: gl_rmain.c:141
r_speeds
cvar_t * r_speeds
Definition: gl_rmain.c:82
GL_ScreenShot_f
void GL_ScreenShot_f(void)
Definition: gl_rmisc.c:100
Draw_GetPicSize
void Draw_GetPicSize(int *w, int *h, char *pic)
Definition: r_draw.c:321
dsprframe_t::origin_y
int origin_y
Definition: qfiles.h:177
entity_s
Definition: ref.h:49
GL_ShutdownImages
void GL_ShutdownImages(void)
Definition: gl_image.c:1571
RF_FULLBRIGHT
#define RF_FULLBRIGHT
Definition: q_shared.h:602
GL_TexEnv
void GL_TexEnv(GLenum mode)
Definition: gl_image.c:126
R_RenderView
void R_RenderView(refdef_t *fd)
Definition: gl_rmain.c:818
vid
viddef_t vid
Definition: gl_rmain.c:31
GL_UpdateSwapInterval
void GL_UpdateSwapInterval(void)
Definition: gl_rmisc.c:232
currententity
entity_t * currententity
Definition: gl_rmain.c:47
vup
vec3_t vup
Definition: gl_rmain.c:64
CVAR_USERINFO
#define CVAR_USERINFO
Definition: q_shared.h:317
gl_ext_pointparameters
cvar_t * gl_ext_pointparameters
Definition: gl_rmain.c:106
c_visible_textures
int c_visible_textures
Definition: gl_rsurf.c:41
R_SetLightLevel
void R_SetLightLevel(void)
Definition: gl_rmain.c:934
VectorMA
void VectorMA(vec3_t veca, float scale, vec3_t vecb, vec3_t vecc)
Definition: q_shared.c:719
mod_alias
@ mod_alias
Definition: r_model.h:169
gl_local.h
R_Clear
void R_Clear(void)
Definition: gl_rmain.c:768
r_rawpalette
unsigned r_rawpalette[256]
Definition: gl_rmain.c:1572
refdef_t::fov_x
float fov_x
Definition: ref.h:105
refexport_t::Shutdown
void(* Shutdown)(void)
Definition: ref.h:142
glconfig_t::vendor_string
const char * vendor_string
Definition: gl_local.h:400
refexport_t::DrawStretchPic
void(* DrawStretchPic)(int x, int y, int w, int h, char *name)
Definition: ref.h:168
GL_RENDERER_3DLABS
#define GL_RENDERER_3DLABS
Definition: gl_local.h:371
refdef_t::fov_y
float fov_y
Definition: ref.h:105
particle_t::color
int color
Definition: ref.h:92
GL_DrawStereoPattern
static void GL_DrawStereoPattern(void)
Definition: gl_rmain.c:896
R_DrawEntitiesOnList
void R_DrawEntitiesOnList(void)
Definition: gl_rmain.c:324
gl_ext_compiled_vertex_array
cvar_t * gl_ext_compiled_vertex_array
Definition: gl_rmain.c:107
gl_particle_att_b
cvar_t * gl_particle_att_b
Definition: gl_rmain.c:100
gl_log
cvar_t * gl_log
Definition: gl_rmain.c:109
Draw_TileClear
void Draw_TileClear(int x, int y, int w, int h, char *name)
Definition: r_draw.c:537
dsprframe_t
Definition: qfiles.h:174
GL_Strings_f
void GL_Strings_f(void)
Definition: gl_rmisc.c:165
refexport_t::api_version
int api_version
Definition: ref.h:136
gl_nobind
cvar_t * gl_nobind
Definition: gl_rmain.c:119
GLimp_EndFrame
void GLimp_EndFrame(void)
Definition: glw_imp.c:561
refdef_t::width
int width
Definition: ref.h:104
refexport_t::DrawTileClear
void(* DrawTileClear)(int x, int y, int w, int h, char *name)
Definition: ref.h:170
refexport_t::DrawChar
void(* DrawChar)(int x, int y, int c)
Definition: ref.h:169
gl_dynamic
cvar_t * gl_dynamic
Definition: gl_rmain.c:116
R_DrawAlphaSurfaces
void R_DrawAlphaSurfaces(void)
Definition: r_poly.c:1342
r_framecount
int r_framecount
Definition: gl_rmain.c:53
R_DrawParticles
void R_DrawParticles(void)
Definition: gl_rmain.c:475
dsprframe_t::origin_x
int origin_x
Definition: qfiles.h:177
R_RegisterModel
struct model_s * R_RegisterModel(char *name)
Definition: r_model.c:1239
gl_config
glconfig_t gl_config
Definition: gl_rmain.c:41
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
gl_flashblend
cvar_t * gl_flashblend
Definition: gl_rmain.c:129
gl_particle_size
cvar_t * gl_particle_size
Definition: gl_rmain.c:98
right
GLdouble right
Definition: qgl_win.c:159
glconfig_t::allow_cds
qboolean allow_cds
Definition: gl_local.h:404
refimport_t::Cvar_SetValue
void(* Cvar_SetValue)(char *name, float value)
Definition: ref.h:218
image_s
Definition: r_local.h:71
refdef_t::viewangles
float viewangles[3]
Definition: ref.h:107
particles
cparticle_t particles[MAX_PARTICLES]
Definition: cl_fx.c:887
refdef_t::entities
entity_t * entities
Definition: ref.h:117
refdef_t::x
int x
Definition: ref.h:104
R_InitParticleTexture
void R_InitParticleTexture(void)
Definition: gl_rmisc.c:41
R_MarkLeaves
void R_MarkLeaves(void)
Definition: r_main.c:467
cplane_s
Definition: q_shared.h:413
QGL_Shutdown
void QGL_Shutdown(void)
Definition: qgl_win.c:2643
Draw_Fill
void Draw_Fill(int x, int y, int w, int h, int c)
Definition: r_draw.c:586
Draw_StretchPic
void Draw_StretchPic(int x, int y, int w, int h, char *name)
Definition: r_draw.c:405
gl_lightmap
cvar_t * gl_lightmap
Definition: gl_rmain.c:113
frustum
cplane_t frustum[4]
Definition: gl_rmain.c:50
refexport_t::Init
qboolean(* Init)(void *hinstance, void *wndproc)
Definition: ref.h:139
gl_round_down
cvar_t * gl_round_down
Definition: gl_rmain.c:120
Mod_Modellist_f
void Mod_Modellist_f(void)
Definition: r_model.c:55
gl_ext_multitexture
cvar_t * gl_ext_multitexture
Definition: gl_rmain.c:105
GL_InitImages
void GL_InitImages(void)
Definition: gl_image.c:1509
GL_SetDefaultState
void GL_SetDefaultState(void)
Definition: gl_rmisc.c:176
rserr_invalid_fullscreen
@ rserr_invalid_fullscreen
Definition: r_local.h:107
entity_s::oldorigin
float oldorigin[3]
Definition: ref.h:63
vpn
vec3_t vpn
Definition: gl_rmain.c:65
glconfig_t::version_string
const char * version_string
Definition: gl_local.h:401
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
refexport_t::RenderFrame
void(* RenderFrame)(refdef_t *fd)
Definition: ref.h:164
GLsizei
GLsizei
Definition: qgl_win.c:408
r_fullbright
cvar_t * r_fullbright
Definition: gl_rmain.c:83
entity_s::angles
float angles[3]
Definition: ref.h:52
r_notexture
image_t * r_notexture
Definition: gl_rmain.c:44
gl_particle_att_c
cvar_t * gl_particle_att_c
Definition: gl_rmain.c:101
void
void(APIENTRY *qglAccum)(GLenum op
RotatePointAroundVector
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Definition: q_shared.c:32
GL_DrawParticles
void GL_DrawParticles(int num_particles, const particle_t particles[], const unsigned colortable[768])
Definition: gl_rmain.c:415
vid_fullscreen
cvar_t * vid_fullscreen
Definition: gl_rmain.c:140
vright
vec3_t vright
Definition: gl_rmain.c:66
QGL_Init
qboolean QGL_Init(const char *dllname)
Definition: qgl_win.c:3032
r_lightlevel
cvar_t * r_lightlevel
Definition: gl_rmain.c:89
R_CullBox
qboolean R_CullBox(vec3_t mins, vec3_t maxs)
Definition: gl_rmain.c:151
R_SetGL2D
void R_SetGL2D(void)
Definition: gl_rmain.c:870
R_EndWorldRenderpass
void R_EndWorldRenderpass(void)
Definition: gl_rmain.c:1562
R_DrawAliasModel
void R_DrawAliasModel(entity_t *e)
Definition: gl_mesh.c:519
shadelight
float shadelight[3]
Definition: r_local.h:645