icculus quake2 doxygen  1.0 dev
r_main.c
Go to the documentation of this file.
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 // r_main.c
21 
22 #include "r_local.h"
23 
26 
27 unsigned d_8to24table[256];
28 
30 
32 float skyrotate;
35 
38 
40 
42 
44 
45 void *colormap;
48 float r_time1;
50 float r_aliasuvscale = 1.0;
53 
55 
57 
58 int c_surf;
62 
63 //
64 // view origin
65 //
70 
71 //
72 // screen size info
73 //
76 float xscale, yscale;
80 
82 
85 
87 
88 //
89 // refresh flags
90 //
91 int r_framecount = 1; // so frame counts initialized to 0 don't match
97 
100 
103 
105 
108 
109 void R_MarkLeaves (void);
110 
125 
132 
134 cvar_t *r_lightlevel; //FIXME HACK
135 
138 
139 //PGM
141 //PGM
142 
143 #define STRINGER(x) "x"
144 
145 
146 #if !id386
147 
148 // r_vars.c
149 
150 // all global and static refresh variables are collected in a contiguous block
151 // to avoid cache conflicts.
152 
153 //-------------------------------------------------------
154 // global refresh variables
155 //-------------------------------------------------------
156 
157 // FIXME: make into one big structure, like cl or sv
158 // FIXME: do separately for refresh engine and driver
159 
160 
161 // d_vars.c
162 
163 // all global and static refresh variables are collected in a contiguous block
164 // to avoid cache conflicts.
165 
166 //-------------------------------------------------------
167 // global refresh variables
168 //-------------------------------------------------------
169 
170 // FIXME: make into one big structure, like cl or sv
171 // FIXME: do separately for refresh engine and driver
172 
176 
178 
182 short *d_pzbuffer;
183 unsigned int d_zrowbytes;
184 unsigned int d_zwidth;
185 
186 
187 #endif // !id386
188 
190 
191 /*
192 ==================
193 R_InitTextures
194 ==================
195 */
196 void R_InitTextures (void)
197 {
198  int x,y, m;
199  byte *dest;
200 
201 // create a simple checkerboard texture for the default
203 
206  r_notexture_mip->pixels[1] = r_notexture_mip->pixels[0] + 16*16;
209 
210  for (m=0 ; m<4 ; m++)
211  {
212  dest = r_notexture_mip->pixels[m];
213  for (y=0 ; y< (16>>m) ; y++)
214  for (x=0 ; x< (16>>m) ; x++)
215  {
216  if ( (y< (8>>m) ) ^ (x< (8>>m) ) )
217 
218  *dest++ = 0;
219  else
220  *dest++ = 0xff;
221  }
222  }
223 }
224 
225 
226 /*
227 ================
228 R_InitTurb
229 ================
230 */
231 void R_InitTurb (void)
232 {
233  int i;
234 
235  for (i=0 ; i<1280 ; i++)
236  {
237  sintable[i] = AMP + sin(i*3.14159*2/CYCLE)*AMP;
238  intsintable[i] = AMP2 + sin(i*3.14159*2/CYCLE)*AMP2; // AMP2, not 20
239  blanktable[i] = 0; //PGM
240  }
241 }
242 
243 void R_ImageList_f( void );
244 
245 void R_Register (void)
246 {
247  sw_aliasstats = ri.Cvar_Get ("sw_polymodelstats", "0", 0);
248  sw_allow_modex = ri.Cvar_Get( "sw_allow_modex", "1", CVAR_ARCHIVE );
249  sw_clearcolor = ri.Cvar_Get ("sw_clearcolor", "2", 0);
250  sw_drawflat = ri.Cvar_Get ("sw_drawflat", "0", 0);
251  sw_draworder = ri.Cvar_Get ("sw_draworder", "0", 0);
252  sw_maxedges = ri.Cvar_Get ("sw_maxedges", STRINGER(MAXSTACKSURFACES), 0);
253  sw_maxsurfs = ri.Cvar_Get ("sw_maxsurfs", "0", 0);
254  sw_mipcap = ri.Cvar_Get ("sw_mipcap", "0", 0);
255  sw_mipscale = ri.Cvar_Get ("sw_mipscale", "1", 0);
256  sw_reportedgeout = ri.Cvar_Get ("sw_reportedgeout", "0", 0);
257  sw_reportsurfout = ri.Cvar_Get ("sw_reportsurfout", "0", 0);
258  sw_stipplealpha = ri.Cvar_Get( "sw_stipplealpha", "0", CVAR_ARCHIVE );
259  sw_surfcacheoverride = ri.Cvar_Get ("sw_surfcacheoverride", "0", 0);
260  sw_waterwarp = ri.Cvar_Get ("sw_waterwarp", "1", 0);
261  sw_mode = ri.Cvar_Get( "sw_mode", "0", CVAR_ARCHIVE );
262 
263  r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
264  r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
265  r_fullbright = ri.Cvar_Get ("r_fullbright", "0", 0);
266  r_drawentities = ri.Cvar_Get ("r_drawentities", "1", 0);
267  r_drawworld = ri.Cvar_Get ("r_drawworld", "1", 0);
268  r_dspeeds = ri.Cvar_Get ("r_dspeeds", "0", 0);
269  r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0);
270  r_lerpmodels = ri.Cvar_Get( "r_lerpmodels", "1", 0 );
271  r_novis = ri.Cvar_Get( "r_novis", "0", 0 );
272 
273  vid_fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE );
274  vid_gamma = ri.Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE );
275 
276  ri.Cmd_AddCommand ("modellist", Mod_Modellist_f);
277  ri.Cmd_AddCommand( "screenshot", R_ScreenShot_f );
278  ri.Cmd_AddCommand( "imagelist", R_ImageList_f );
279 
280  sw_mode->modified = true; // force us to do mode specific stuff later
281  vid_gamma->modified = true; // force us to rebuild the gamma table later
282 
283 //PGM
284  sw_lockpvs = ri.Cvar_Get ("sw_lockpvs", "0", 0);
285 //PGM
286 }
287 
288 void R_UnRegister (void)
289 {
290  ri.Cmd_RemoveCommand( "screenshot" );
291  ri.Cmd_RemoveCommand ("modellist");
292  ri.Cmd_RemoveCommand( "imagelist" );
293 }
294 
295 /*
296 ===============
297 R_Init
298 ===============
299 */
300 int R_Init( void *hInstance, void *wndProc )
301 {
302  R_InitImages ();
303  Mod_Init ();
304  Draw_InitLocal ();
305  R_InitTextures ();
306 
307  R_InitTurb ();
308 
309  view_clipplanes[0].leftedge = true;
310  view_clipplanes[1].rightedge = true;
312  view_clipplanes[3].leftedge = false;
314  view_clipplanes[3].rightedge = false;
315 
318 
319 // TODO: collect 386-specific code in one place
320 #if id386
322  (long)R_EdgeCodeEnd - (long)R_EdgeCodeStart);
323  Sys_SetFPCW (); // get bit masks for FPCW (FIXME: is this id386?)
324 #endif // id386
325 
326  r_aliasuvscale = 1.0;
327 
328  R_Register ();
329  Draw_GetPalette ();
330  if (SWimp_Init( hInstance, wndProc ) == false)
331  return -1;
332 
333  // create the window
334  R_BeginFrame( 0 );
335 
336  ri.Con_Printf (PRINT_ALL, "ref_soft version: "REF_VERSION"\n");
337 
338  return true;
339 }
340 
341 /*
342 ===============
343 R_Shutdown
344 ===============
345 */
346 void R_Shutdown (void)
347 {
348  // free z buffer
349  if (d_pzbuffer)
350  {
351  free (d_pzbuffer);
352  d_pzbuffer = NULL;
353  }
354  // free surface cache
355  if (sc_base)
356  {
357  D_FlushCaches ();
358  free (sc_base);
359  sc_base = NULL;
360  }
361 
362  // free colormap
363  if (vid.colormap)
364  {
365  free (vid.colormap);
366  vid.colormap = NULL;
367  }
368  R_UnRegister ();
369  Mod_FreeAll ();
370  R_ShutdownImages ();
371 
372  SWimp_Shutdown();
373 }
374 
375 /*
376 ===============
377 R_NewMap
378 ===============
379 */
380 void R_NewMap (void)
381 {
382  r_viewcluster = -1;
383 
385 
386  if (r_cnumsurfs <= MINSURFACES)
388 
390  {
391  surfaces = malloc (r_cnumsurfs * sizeof(surf_t));
394  r_surfsonstack = false;
395  // surface 0 doesn't really exist; it's just a dummy because index 0
396  // is used to indicate no edge attached to surface
397  surfaces--;
398  R_SurfacePatch ();
399  }
400  else
401  {
402  r_surfsonstack = true;
403  }
404 
405  r_maxedgesseen = 0;
406  r_maxsurfsseen = 0;
407 
409 
412 
414  {
415  auxedges = NULL;
416  }
417  else
418  {
419  auxedges = malloc (r_numallocatededges * sizeof(edge_t));
420  }
421 }
422 
423 
424 /*
425 ===============
426 R_MarkLeaves
427 
428 Mark the leaves and nodes that are in the PVS for the current
429 cluster
430 ===============
431 */
432 void R_MarkLeaves (void)
433 {
434  byte *vis;
435  mnode_t *node;
436  int i;
437  mleaf_t *leaf;
438  int cluster;
439 
441  return;
442 
443  // development aid to let you run around and see exactly where
444  // the pvs ends
445  if (sw_lockpvs->value)
446  return;
447 
448  r_visframecount++;
450 
451  if (r_novis->value || r_viewcluster == -1 || !r_worldmodel->vis)
452  {
453  // mark everything
454  for (i=0 ; i<r_worldmodel->numleafs ; i++)
456  for (i=0 ; i<r_worldmodel->numnodes ; i++)
458  return;
459  }
460 
462 
463  for (i=0,leaf=r_worldmodel->leafs ; i<r_worldmodel->numleafs ; i++, leaf++)
464  {
465  cluster = leaf->cluster;
466  if (cluster == -1)
467  continue;
468  if (vis[cluster>>3] & (1<<(cluster&7)))
469  {
470  node = (mnode_t *)leaf;
471  do
472  {
473  if (node->visframe == r_visframecount)
474  break;
475  node->visframe = r_visframecount;
476  node = node->parent;
477  } while (node);
478  }
479  }
480 
481 #if 0
482  for (i=0 ; i<r_worldmodel->vis->numclusters ; i++)
483  {
484  if (vis[i>>3] & (1<<(i&7)))
485  {
486  node = (mnode_t *)&r_worldmodel->leafs[i]; // FIXME: cluster
487  do
488  {
489  if (node->visframe == r_visframecount)
490  break;
491  node->visframe = r_visframecount;
492  node = node->parent;
493  } while (node);
494  }
495  }
496 #endif
497 }
498 
499 /*
500 ** R_DrawNullModel
501 **
502 ** IMPLEMENT THIS!
503 */
504 void R_DrawNullModel( void )
505 {
506 }
507 
508 /*
509 =============
510 R_DrawEntitiesOnList
511 =============
512 */
514 {
515  int i;
516  qboolean translucent_entities = false;
517 
518  if (!r_drawentities->value)
519  return;
520 
521  // all bmodels have already been drawn by the edge list
522  for (i=0 ; i<r_newrefdef.num_entities ; i++)
523  {
525 
527  {
528  translucent_entities = true;
529  continue;
530  }
531 
532  if ( currententity->flags & RF_BEAM )
533  {
534  modelorg[0] = -r_origin[0];
535  modelorg[1] = -r_origin[1];
536  modelorg[2] = -r_origin[2];
539  }
540  else
541  {
543  if (!currentmodel)
544  {
545  R_DrawNullModel();
546  continue;
547  }
550 
551  switch (currentmodel->type)
552  {
553  case mod_sprite:
554  R_DrawSprite ();
555  break;
556 
557  case mod_alias:
558  R_AliasDrawModel ();
559  break;
560 
561  default:
562  break;
563  }
564  }
565  }
566 
567  if ( !translucent_entities )
568  return;
569 
570  for (i=0 ; i<r_newrefdef.num_entities ; i++)
571  {
573 
574  if ( !( currententity->flags & RF_TRANSLUCENT ) )
575  continue;
576 
577  if ( currententity->flags & RF_BEAM )
578  {
579  modelorg[0] = -r_origin[0];
580  modelorg[1] = -r_origin[1];
581  modelorg[2] = -r_origin[2];
584  }
585  else
586  {
588  if (!currentmodel)
589  {
590  R_DrawNullModel();
591  continue;
592  }
595 
596  switch (currentmodel->type)
597  {
598  case mod_sprite:
599  R_DrawSprite ();
600  break;
601 
602  case mod_alias:
603  R_AliasDrawModel ();
604  break;
605 
606  default:
607  break;
608  }
609  }
610  }
611 }
612 
613 
614 /*
615 =============
616 R_BmodelCheckBBox
617 =============
618 */
619 int R_BmodelCheckBBox (float *minmaxs)
620 {
621  int i, *pindex, clipflags;
622  vec3_t acceptpt, rejectpt;
623  float d;
624 
625  clipflags = 0;
626 
627  for (i=0 ; i<4 ; i++)
628  {
629  // generate accept and reject points
630  // FIXME: do with fast look-ups or integer tests based on the sign bit
631  // of the floating point values
632 
633  pindex = pfrustum_indexes[i];
634 
635  rejectpt[0] = minmaxs[pindex[0]];
636  rejectpt[1] = minmaxs[pindex[1]];
637  rejectpt[2] = minmaxs[pindex[2]];
638 
639  d = DotProduct (rejectpt, view_clipplanes[i].normal);
640  d -= view_clipplanes[i].dist;
641 
642  if (d <= 0)
643  return BMODEL_FULLY_CLIPPED;
644 
645  acceptpt[0] = minmaxs[pindex[3+0]];
646  acceptpt[1] = minmaxs[pindex[3+1]];
647  acceptpt[2] = minmaxs[pindex[3+2]];
648 
649  d = DotProduct (acceptpt, view_clipplanes[i].normal);
650  d -= view_clipplanes[i].dist;
651 
652  if (d <= 0)
653  clipflags |= (1<<i);
654  }
655 
656  return clipflags;
657 }
658 
659 
660 /*
661 ===================
662 R_FindTopnode
663 
664 Find the first node that splits the given box
665 ===================
666 */
668 {
669  mplane_t *splitplane;
670  int sides;
671  mnode_t *node;
672 
673  node = r_worldmodel->nodes;
674 
675  while (1)
676  {
677  if (node->visframe != r_visframecount)
678  return NULL; // not visible at all
679 
680  if (node->contents != CONTENTS_NODE)
681  {
682  if (node->contents != CONTENTS_SOLID)
683  return node; // we've reached a non-solid leaf, so it's
684  // visible and not BSP clipped
685  return NULL; // in solid, so not visible
686  }
687 
688  splitplane = node->plane;
689  sides = BOX_ON_PLANE_SIDE(mins, maxs, (cplane_t *)splitplane);
690 
691  if (sides == 3)
692  return node; // this is the splitter
693 
694  // not split yet; recurse down the contacted side
695  if (sides & 1)
696  node = node->children[0];
697  else
698  node = node->children[1];
699  }
700 }
701 
702 
703 /*
704 =============
705 RotatedBBox
706 
707 Returns an axially aligned box that contains the input box at the given rotation
708 =============
709 */
710 void RotatedBBox (vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t tmaxs)
711 {
712  vec3_t tmp, v;
713  int i, j;
715 
716  if (!angles[0] && !angles[1] && !angles[2])
717  {
718  VectorCopy (mins, tmins);
719  VectorCopy (maxs, tmaxs);
720  return;
721  }
722 
723  for (i=0 ; i<3 ; i++)
724  {
725  tmins[i] = 99999;
726  tmaxs[i] = -99999;
727  }
728 
729  AngleVectors (angles, forward, right, up);
730 
731  for ( i = 0; i < 8; i++ )
732  {
733  if ( i & 1 )
734  tmp[0] = mins[0];
735  else
736  tmp[0] = maxs[0];
737 
738  if ( i & 2 )
739  tmp[1] = mins[1];
740  else
741  tmp[1] = maxs[1];
742 
743  if ( i & 4 )
744  tmp[2] = mins[2];
745  else
746  tmp[2] = maxs[2];
747 
748 
749  VectorScale (forward, tmp[0], v);
750  VectorMA (v, -tmp[1], right, v);
751  VectorMA (v, tmp[2], up, v);
752 
753  for (j=0 ; j<3 ; j++)
754  {
755  if (v[j] < tmins[j])
756  tmins[j] = v[j];
757  if (v[j] > tmaxs[j])
758  tmaxs[j] = v[j];
759  }
760  }
761 }
762 
763 /*
764 =============
765 R_DrawBEntitiesOnList
766 =============
767 */
769 {
770  int i, clipflags;
771  vec3_t oldorigin;
772  vec3_t mins, maxs;
773  float minmaxs[6];
774  mnode_t *topnode;
775 
776  if (!r_drawentities->value)
777  return;
778 
779  VectorCopy (modelorg, oldorigin);
780  insubmodel = true;
782 
783  for (i=0 ; i<r_newrefdef.num_entities ; i++)
784  {
787  if (!currentmodel)
788  continue;
789  if (currentmodel->nummodelsurfaces == 0)
790  continue; // clip brush only
791  if ( currententity->flags & RF_BEAM )
792  continue;
793  if (currentmodel->type != mod_brush)
794  continue;
795  // see if the bounding box lets us trivially reject, also sets
796  // trivial accept status
798  currententity->angles, mins, maxs);
799  VectorAdd (mins, currententity->origin, minmaxs);
800  VectorAdd (maxs, currententity->origin, (minmaxs+3));
801 
802  clipflags = R_BmodelCheckBBox (minmaxs);
803  if (clipflags == BMODEL_FULLY_CLIPPED)
804  continue; // off the edge of the screen
805 
806  topnode = R_FindTopnode (minmaxs, minmaxs+3);
807  if (!topnode)
808  continue; // no part in a visible leaf
809 
812 
814 
815  // FIXME: stop transforming twice
816  R_RotateBmodel ();
817 
818  // calculate dynamic lighting for bmodel
820 
821  if (topnode->contents == CONTENTS_NODE)
822  {
823  // not a leaf; has to be clipped to the world BSP
824  r_clipflags = clipflags;
826  }
827  else
828  {
829  // falls entirely in one leaf, so we just put all the
830  // edges in the edge list and let 1/z sorting handle
831  // drawing order
832  R_DrawSubmodelPolygons (currentmodel, clipflags, topnode);
833  }
834 
835  // put back world rotation and frustum clipping
836  // FIXME: R_RotateBmodel should just work off base_vxx
840  VectorCopy (oldorigin, modelorg);
842  }
843 
844  insubmodel = false;
845 }
846 
847 
848 /*
849 ================
850 R_EdgeDrawing
851 ================
852 */
853 void R_EdgeDrawing (void)
854 {
855  edge_t ledges[NUMSTACKEDGES +
856  ((CACHE_SIZE - 1) / sizeof(edge_t)) + 1];
857  surf_t lsurfs[NUMSTACKSURFACES +
858  ((CACHE_SIZE - 1) / sizeof(surf_t)) + 1];
859 
861  return;
862 
863  if (auxedges)
864  {
865  r_edges = auxedges;
866  }
867  else
868  {
869  r_edges = (edge_t *)
870  (((long)&ledges[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
871  }
872 
873  if (r_surfsonstack)
874  {
875  surfaces = (surf_t *)
876  (((long)&lsurfs[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
878  // surface 0 doesn't really exist; it's just a dummy because index 0
879  // is used to indicate no edge attached to surface
880  surfaces--;
881  R_SurfacePatch ();
882  }
883 
884  R_BeginEdgeFrame ();
885 
886  if (r_dspeeds->value)
887  {
889  }
890 
891  R_RenderWorld ();
892 
893  if (r_dspeeds->value)
894  {
896  db_time1 = rw_time2;
897  }
898 
900 
901  if (r_dspeeds->value)
902  {
904  se_time1 = db_time2;
905  }
906 
907  R_ScanEdges ();
908 }
909 
910 //=======================================================================
911 
912 
913 /*
914 =============
915 R_CalcPalette
916 
917 =============
918 */
919 void R_CalcPalette (void)
920 {
921  static qboolean modified;
922  byte palette[256][4], *in, *out;
923  int i, j;
924  float alpha, one_minus_alpha;
925  vec3_t premult;
926  int v;
927 
928  alpha = r_newrefdef.blend[3];
929  if (alpha <= 0)
930  {
931  if (modified)
932  { // set back to default
933  modified = false;
934  R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
935  return;
936  }
937  return;
938  }
939 
940  modified = true;
941  if (alpha > 1)
942  alpha = 1;
943 
944  premult[0] = r_newrefdef.blend[0]*alpha*255;
945  premult[1] = r_newrefdef.blend[1]*alpha*255;
946  premult[2] = r_newrefdef.blend[2]*alpha*255;
947 
948  one_minus_alpha = (1.0 - alpha);
949 
950  in = (byte *)d_8to24table;
951  out = palette[0];
952  for (i=0 ; i<256 ; i++, in+=4, out+=4)
953  {
954  for (j=0 ; j<3 ; j++)
955  {
956  v = premult[j] + one_minus_alpha * in[j];
957  if (v > 255)
958  v = 255;
959  out[j] = v;
960  }
961  out[3] = 255;
962  }
963 
964  R_GammaCorrectAndSetPalette( ( const unsigned char * ) palette[0] );
965 // SWimp_SetPalette( palette[0] );
966 }
967 
968 //=======================================================================
969 
970 void R_SetLightLevel (void)
971 {
972  vec3_t light;
973 
975  {
976  r_lightlevel->value = 150.0;
977  return;
978  }
979 
980  // save off light value for server to look at (BIG HACK!)
982  r_lightlevel->value = 150.0 * light[0];
983 }
984 
985 
986 /*
987 @@@@@@@@@@@@@@@@
988 R_RenderFrame
989 
990 @@@@@@@@@@@@@@@@
991 */
993 {
994  r_newrefdef = *fd;
995 
997  ri.Sys_Error (ERR_FATAL,"R_RenderView: NULL worldmodel");
998 
1001 
1002  if (r_speeds->value || r_dspeeds->value)
1004 
1005  R_SetupFrame ();
1006 
1007  R_MarkLeaves (); // done here so we know if we're in water
1008 
1010 
1011  R_EdgeDrawing ();
1012 
1013  if (r_dspeeds->value)
1014  {
1016  de_time1 = se_time2;
1017  }
1018 
1020 
1021  if (r_dspeeds->value)
1022  {
1025  }
1026 
1027  R_DrawParticles ();
1028 
1029  if (r_dspeeds->value)
1031 
1033 
1034  R_SetLightLevel ();
1035 
1036  if (r_dowarp)
1037  D_WarpScreen ();
1038 
1039  if (r_dspeeds->value)
1041 
1042  if (r_dspeeds->value)
1044 
1045  R_CalcPalette ();
1046 
1047  if (sw_aliasstats->value)
1048  R_PrintAliasStats ();
1049 
1050  if (r_speeds->value)
1051  R_PrintTimes ();
1052 
1053  if (r_dspeeds->value)
1054  R_PrintDSpeeds ();
1055 
1057  ri.Con_Printf (PRINT_ALL,"Short %d surfaces\n", r_outofsurfaces);
1058 
1060  ri.Con_Printf (PRINT_ALL,"Short roughly %d edges\n", r_outofedges * 2 / 3);
1061 }
1062 
1063 /*
1064 ** R_InitGraphics
1065 */
1066 void R_InitGraphics( int width, int height )
1067 {
1068  vid.width = width;
1069  vid.height = height;
1070 
1071  // free z buffer
1072  if ( d_pzbuffer )
1073  {
1074  free( d_pzbuffer );
1075  d_pzbuffer = NULL;
1076  }
1077 
1078  // free surface cache
1079  if ( sc_base )
1080  {
1081  D_FlushCaches ();
1082  free( sc_base );
1083  sc_base = NULL;
1084  }
1085 
1086  d_pzbuffer = malloc(vid.width*vid.height*2);
1087 
1088  R_InitCaches ();
1089 
1090  R_GammaCorrectAndSetPalette( ( const unsigned char *) d_8to24table );
1091 }
1092 
1093 #ifdef REDBLUE
1094 void SetStereoBuffer(int buf);
1095 #endif
1096 /*
1097 ** R_BeginFrame
1098 */
1099 void R_BeginFrame( float camera_separation )
1100 {
1101  extern void Draw_BuildGammaTable( void );
1102 #ifdef REDBLUE
1103  SetStereoBuffer((camera_separation <= 0.0) ? 0 : 1);
1104 #endif
1105  /*
1106  ** rebuild the gamma correction palette if necessary
1107  */
1108  if ( vid_gamma->modified )
1109  {
1111  R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
1112 
1113  vid_gamma->modified = false;
1114  }
1115 
1116  while ( sw_mode->modified || vid_fullscreen->modified )
1117  {
1118  rserr_t err;
1119 
1120  /*
1121  ** if this returns rserr_invalid_fullscreen then it set the mode but not as a
1122  ** fullscreen mode, e.g. 320x200 on a system that doesn't support that res
1123  */
1124  if ( ( err = SWimp_SetMode( &vid.width, &vid.height, sw_mode->value, vid_fullscreen->value ) ) == rserr_ok )
1125  {
1127 
1129  vid_fullscreen->modified = false;
1130  sw_mode->modified = false;
1131  }
1132  else
1133  {
1134  if ( err == rserr_invalid_mode )
1135  {
1136  ri.Cvar_SetValue( "sw_mode", sw_state.prev_mode );
1137  ri.Con_Printf( PRINT_ALL, "ref_soft::R_BeginFrame() - could not set mode\n" );
1138  }
1139  else if ( err == rserr_invalid_fullscreen )
1140  {
1142 
1143  ri.Cvar_SetValue( "vid_fullscreen", 0);
1144  ri.Con_Printf( PRINT_ALL, "ref_soft::R_BeginFrame() - fullscreen unavailable in this mode\n" );
1146 // vid_fullscreen->modified = false;
1147 // sw_mode->modified = false;
1148  }
1149  else
1150  {
1151  ri.Sys_Error( ERR_FATAL, "ref_soft::R_BeginFrame() - catastrophic mode change failure\n" );
1152  }
1153  }
1154  }
1155 }
1156 
1157 /*
1158 ** R_GammaCorrectAndSetPalette
1159 */
1160 void R_GammaCorrectAndSetPalette( const unsigned char *palette )
1161 {
1162  int i;
1163 
1164  for ( i = 0; i < 256; i++ )
1165  {
1166  sw_state.currentpalette[i*4+0] = sw_state.gammatable[palette[i*4+0]];
1167  sw_state.currentpalette[i*4+1] = sw_state.gammatable[palette[i*4+1]];
1168  sw_state.currentpalette[i*4+2] = sw_state.gammatable[palette[i*4+2]];
1169  }
1170 
1172 }
1173 
1174 /*
1175 ** R_CinematicSetPalette
1176 */
1177 void R_CinematicSetPalette( const unsigned char *palette )
1178 {
1179  byte palette32[1024];
1180  int i, j, w;
1181  int *d;
1182 
1183  // clear screen to black to avoid any palette flash
1184  w = abs(vid.rowbytes)>>2; // stupid negative pitch win32 stuff...
1185  for (i=0 ; i<vid.height ; i++, d+=w)
1186  {
1187  d = (int *)(vid.buffer + i*vid.rowbytes);
1188  for (j=0 ; j<w ; j++)
1189  d[j] = 0;
1190  }
1191  // flush it to the screen
1192  SWimp_EndFrame ();
1193 
1194  if ( palette )
1195  {
1196  for ( i = 0; i < 256; i++ )
1197  {
1198  palette32[i*4+0] = palette[i*3+0];
1199  palette32[i*4+1] = palette[i*3+1];
1200  palette32[i*4+2] = palette[i*3+2];
1201  palette32[i*4+3] = 0xFF;
1202  }
1203 
1204  R_GammaCorrectAndSetPalette( palette32 );
1205  }
1206  else
1207  {
1208  R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
1209  }
1210 }
1211 
1212 /*
1213 ================
1214 Draw_BuildGammaTable
1215 ================
1216 */
1218 {
1219  int i, inf;
1220  float g;
1221 
1222  g = vid_gamma->value;
1223 
1224  if (g == 1.0)
1225  {
1226  for (i=0 ; i<256 ; i++)
1227  sw_state.gammatable[i] = i;
1228  return;
1229  }
1230 
1231  for (i=0 ; i<256 ; i++)
1232  {
1233  inf = 255 * pow ( (i+0.5)/255.5 , g ) + 0.5;
1234  if (inf < 0)
1235  inf = 0;
1236  if (inf > 255)
1237  inf = 255;
1238  sw_state.gammatable[i] = inf;
1239  }
1240 }
1241 
1242 /*
1243 ** R_DrawBeam
1244 */
1246 {
1247 #define NUM_BEAM_SEGS 6
1248 
1249  int i;
1250 
1251  vec3_t perpvec;
1252  vec3_t direction, normalized_direction;
1253  vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
1254  vec3_t oldorigin, origin;
1255 
1256  oldorigin[0] = e->oldorigin[0];
1257  oldorigin[1] = e->oldorigin[1];
1258  oldorigin[2] = e->oldorigin[2];
1259 
1260  origin[0] = e->origin[0];
1261  origin[1] = e->origin[1];
1262  origin[2] = e->origin[2];
1263 
1264  normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
1265  normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
1266  normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
1267 
1268  if ( VectorNormalize( normalized_direction ) == 0 )
1269  return;
1270 
1271  PerpendicularVector( perpvec, normalized_direction );
1272  VectorScale( perpvec, e->frame / 2, perpvec );
1273 
1274  for ( i = 0; i < NUM_BEAM_SEGS; i++ )
1275  {
1276  RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );
1277  VectorAdd( start_points[i], origin, start_points[i] );
1278  VectorAdd( start_points[i], direction, end_points[i] );
1279  }
1280 
1281  for ( i = 0; i < NUM_BEAM_SEGS; i++ )
1282  {
1283  R_IMFlatShadedQuad( start_points[i],
1284  end_points[i],
1285  end_points[(i+1)%NUM_BEAM_SEGS],
1286  start_points[(i+1)%NUM_BEAM_SEGS],
1287  e->skinnum & 0xFF,
1288  e->alpha );
1289  }
1290 }
1291 
1292 
1293 //===================================================================
1294 
1295 /*
1296 ============
1297 R_SetSky
1298 ============
1299 */
1300 // 3dstudio environment map names
1301 char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
1302 int r_skysideimage[6] = {5, 2, 4, 1, 0, 3};
1303 extern mtexinfo_t r_skytexinfo[6];
1304 void R_SetSky (char *name, float rotate, vec3_t axis)
1305 {
1306  int i;
1307  char pathname[MAX_QPATH];
1308 
1309  strncpy (skyname, name, sizeof(skyname)-1);
1310  skyrotate = rotate;
1311  VectorCopy (axis, skyaxis);
1312 
1313  for (i=0 ; i<6 ; i++)
1314  {
1315  Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[r_skysideimage[i]]);
1316  r_skytexinfo[i].image = R_FindImage (pathname, it_sky);
1317  }
1318 }
1319 
1320 
1321 /*
1322 ===============
1323 Draw_GetPalette
1324 ===============
1325 */
1326 void Draw_GetPalette (void)
1327 {
1328  byte *pal, *out;
1329  int i;
1330  int r, g, b;
1331 
1332  // get the palette and colormap
1333  LoadPCX ("pics/colormap.pcx", &vid.colormap, &pal, NULL, NULL);
1334  if (!vid.colormap)
1335  ri.Sys_Error (ERR_FATAL, "Couldn't load pics/colormap.pcx");
1336  vid.alphamap = vid.colormap + 64*256;
1337 
1338  out = (byte *)d_8to24table;
1339  for (i=0 ; i<256 ; i++, out+=4)
1340  {
1341  r = pal[i*3+0];
1342  g = pal[i*3+1];
1343  b = pal[i*3+2];
1344 
1345  out[0] = r;
1346  out[1] = g;
1347  out[2] = b;
1348  }
1349 
1350  free (pal);
1351 }
1352 
1353 struct image_s *R_RegisterSkin (char *name);
1354 
1355 /*
1356 @@@@@@@@@@@@@@@@@@@@@
1357 GetRefAPI
1358 
1359 @@@@@@@@@@@@@@@@@@@@@
1360 */
1362 {
1363  refexport_t re;
1364 
1365  ri = rimp;
1366 
1368 
1373  re.SetSky = R_SetSky;
1375 
1377 
1379 
1380 
1381 #ifdef QMAX
1382  re.DrawScaledPic = Draw_ScaledPic;
1383  re.AddStain = R_AddStain;
1384 #endif
1385 
1386  re.DrawPic = Draw_Pic;
1388  re.DrawChar = Draw_Char;
1390  re.DrawFill = Draw_Fill;
1392 
1394 
1395  re.Init = R_Init;
1397 
1401 
1403 
1404  Swap_Init ();
1405 
1406  return re;
1407 }
1408 
1409 #ifndef REF_HARD_LINKED
1410 // this is only here so the functions in q_shared.c and q_shwin.c can link
1411 void Sys_Error (char *error, ...)
1412 {
1413  va_list argptr;
1414  char text[1024];
1415 
1416  va_start (argptr, error);
1417  vsprintf (text, error, argptr);
1418  va_end (argptr);
1419 
1420  ri.Sys_Error (ERR_FATAL, "%s", text);
1421 }
1422 
1423 void Com_Printf (char *fmt, ...)
1424 {
1425  va_list argptr;
1426  char text[1024];
1427 
1428  va_start (argptr, fmt);
1429  vsprintf (text, fmt, argptr);
1430  va_end (argptr);
1431 
1432  ri.Con_Printf (PRINT_ALL, "%s", text);
1433 }
1434 
1435 #endif
1436 
1437 #ifdef QMAX
1438 void R_AddStain (vec3_t org, float intensity, float r, float g, float b) {
1439 }
1440 
1441 void Draw_ScaledPic (int x, int y, float scale, float alpha, char *pic) {
1442 }
1443 #endif
RF_TRANSLUCENT
#define RF_TRANSLUCENT
Definition: q_shared.h:618
r_pcurrentvertbase
mvertex_t * r_pcurrentvertbase
Definition: r_main.c:56
refexport_t::RegisterSkin
struct image_s *(* RegisterSkin)(char *name)
Definition: ref.h:177
GetRefAPI
refexport_t GetRefAPI(refimport_t rimp)
Definition: r_main.c:1361
r_skytexinfo
mtexinfo_t r_skytexinfo[6]
Definition: r_rast.c:70
refdef_t::vieworg
float vieworg[3]
Definition: ref.h:124
refimport_t::Cmd_RemoveCommand
void(* Cmd_RemoveCommand)(char *name)
Definition: ref.h:223
sw_reportedgeout
cvar_t * sw_reportedgeout
Definition: r_main.c:120
rserr_t
rserr_t
Definition: r_local.h:97
height
GLsizei height
Definition: qgl_win.c:69
d_zrowbytes
unsigned int d_zrowbytes
Definition: r_main.c:183
r_cnumsurfs
int r_cnumsurfs
Definition: r_main.c:59
sky_images
image_t * sky_images[6]
Definition: r_main.c:34
sw_mipscale
cvar_t * sw_mipscale
Definition: r_misc.c:27
R_BeginEdgeFrame
void R_BeginEdgeFrame(void)
Definition: r_edge.c:109
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:73
entity_s::origin
float origin[3]
Definition: ref.h:57
R_Register
void R_Register(void)
Definition: r_main.c:245
entity_s::model
struct model_s * model
Definition: ref.h:51
CONTENTS_NODE
#define CONTENTS_NODE
Definition: r_model.h:122
R_InitImages
void R_InitImages(void)
Definition: r_image.c:607
R_DrawBeam
void R_DrawBeam(entity_t *e)
Definition: r_main.c:1245
yOrigin
float yOrigin
Definition: r_main.c:84
r_novis
cvar_t * r_novis
Definition: r_main.c:131
refdef_t
Definition: ref.h:120
model_s::vis
dvis_t * vis
Definition: r_model.h:229
intsintable
int intsintable[1280]
Definition: r_rast.c:48
oldrefdef_t::vieworg
vec3_t vieworg
Definition: r_local.h:132
r_visframecount
int r_visframecount
Definition: r_main.c:92
sadjust
fixed16_t sadjust
Definition: r_main.c:177
r_drawnpolycount
int r_drawnpolycount
Definition: r_main.c:95
base_vpn
vec3_t base_vpn
Definition: r_main.c:67
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:156
Sys_SetFPCW
void Sys_SetFPCW(void)
Definition: rw_imp.c:437
R_ShutdownImages
void R_ShutdownImages(void)
Definition: r_image.c:617
CYCLE
#define CYCLE
Definition: asm_draw.h:16
r_maxsurfsseen
int r_maxsurfsseen
Definition: r_main.c:59
R_BeginRegistration
void R_BeginRegistration(char *map)
Definition: r_model.c:1139
R_BmodelCheckBBox
int R_BmodelCheckBBox(float *minmaxs)
Definition: r_main.c:619
Swap_Init
void Swap_Init(void)
Definition: q_shared.c:1011
Draw_Char
#define Draw_Char
Definition: qmenu.c:50
sw_reportsurfout
cvar_t * sw_reportsurfout
Definition: r_main.c:121
da_time1
float da_time1
Definition: r_main.c:106
r_lerpmodels
cvar_t * r_lerpmodels
Definition: r_main.c:130
Sys_MakeCodeWriteable
void Sys_MakeCodeWriteable(unsigned long startaddr, unsigned long length)
Definition: rw_imp.c:408
viddef_t::buffer
pixel_t * buffer
Definition: r_local.h:88
r_oldviewcluster
int r_oldviewcluster
Definition: r_main.c:102
d_tdivzorigin
float d_tdivzorigin
Definition: r_main.c:175
insubmodel
qboolean insubmodel
Definition: r_bsp.c:27
mvertex_t
Definition: r_model.h:45
R_ScreenShot_f
void R_ScreenShot_f(void)
Definition: r_misc.c:619
BOX_ON_PLANE_SIDE
#define BOX_ON_PLANE_SIDE(emins, emaxs, p)
Definition: q_shared.h:190
viewlightvec
vec3_t viewlightvec
Definition: r_main.c:46
model_s::nummodelsurfaces
int nummodelsurfaces
Definition: r_model.h:196
skyname
char skyname[MAX_QPATH]
Definition: r_main.c:31
R_PushDlights
void R_PushDlights(model_t *model)
Definition: r_light.c:94
c_surf
int c_surf
Definition: r_main.c:58
Draw_StretchRaw
void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
Definition: r_draw.c:238
R_SurfacePatch
void R_SurfacePatch(void)
Definition: r_misc.c:524
BMODEL_FULLY_CLIPPED
#define BMODEL_FULLY_CLIPPED
Definition: r_local.h:212
oldrefdef_t::viewangles
vec3_t viewangles
Definition: r_local.h:133
d_zistepu
float d_zistepu
Definition: r_main.c:173
R_SetSky
void R_SetSky(char *name, float rotate, vec3_t axis)
Definition: r_main.c:1304
refexport_t::DrawStretchRaw
void(* DrawStretchRaw)(int x, int y, int w, int h, int cols, int rows, byte *data)
Definition: ref.h:202
vright
vec3_t vright
Definition: r_main.c:68
v
GLdouble v
Definition: qgl_win.c:143
cvar_s::modified
qboolean modified
Definition: q_shared.h:323
refexport_t::Init
int(* Init)(void *hinstance, void *wndproc)
Definition: ref.h:157
R_InitGraphics
void R_InitGraphics(int width, int height)
Definition: r_main.c:1066
r_origin
vec3_t r_origin
Definition: r_main.c:69
R_CalcPalette
void R_CalcPalette(void)
Definition: r_main.c:919
CACHE_SIZE
#define CACHE_SIZE
Definition: d_ifacea.h:22
d_8to24table
unsigned d_8to24table[256]
Definition: r_main.c:27
sw_drawflat
cvar_t * sw_drawflat
Definition: r_main.c:115
d_ziorigin
float d_ziorigin
Definition: r_main.c:175
refexport_t::RegisterPic
struct image_s *(* RegisterPic)(char *name)
Definition: ref.h:178
refexport_t::DrawFill
void(* DrawFill)(int x, int y, int w, int h, int c)
Definition: ref.h:198
r_skysideimage
int r_skysideimage[6]
Definition: r_main.c:1302
R_LightPoint
void R_LightPoint(vec3_t p, vec3_t color)
Definition: r_light.c:224
mtexinfo_s
Definition: r_model.h:83
mnode_s::visframe
int visframe
Definition: r_model.h:127
vid
viddef_t vid
Definition: r_main.c:24
de_time1
float de_time1
Definition: r_main.c:107
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:242
sw_draworder
cvar_t * sw_draworder
Definition: r_main.c:116
VectorScale
void VectorScale(vec3_t in, vec_t scale, vec3_t out)
Definition: q_shared.c:782
sw_surfcacheoverride
cvar_t * sw_surfcacheoverride
Definition: r_main.c:123
R_FindImage
image_t * R_FindImage(char *name, imagetype_t type)
Definition: r_image.c:497
qboolean
qboolean
Definition: q_shared.h:56
x
GLint GLenum GLint x
Definition: qgl_win.c:116
viddef_t::width
int width
Definition: vid.h:29
oldrefdef_t::xOrigin
float xOrigin
Definition: r_local.h:129
entity_s::skinnum
int skinnum
Definition: ref.h:70
d_sdivzorigin
float d_sdivzorigin
Definition: r_main.c:175
SWimp_AppActivate
void SWimp_AppActivate(qboolean active)
Definition: rw_imp.c:378
i
int i
Definition: q_shared.c:305
surf_max
surf_t * surf_max
Definition: r_edge.c:51
API_VERSION
#define API_VERSION
Definition: ref.h:146
modelorg
vec3_t modelorg
Definition: r_bsp.c:29
skyaxis
vec3_t skyaxis
Definition: r_main.c:33
R_DrawSprite
void R_DrawSprite(void)
Definition: r_sprite.c:40
db_time1
float db_time1
Definition: r_main.c:106
mleaf_s::visframe
int visframe
Definition: r_model.h:147
mnode_s::parent
struct mnode_s * parent
Definition: r_model.h:131
sw_lockpvs
cvar_t * sw_lockpvs
Definition: r_main.c:140
mnode_s
Definition: r_model.h:123
sw_clearcolor
cvar_t * sw_clearcolor
Definition: r_main.c:114
model_s
Definition: r_model.h:171
viddef_t::height
int height
Definition: vid.h:29
r_aliasuvscale
float r_aliasuvscale
Definition: r_main.c:50
refdef_t::rdflags
int rdflags
Definition: ref.h:128
SWimp_Shutdown
void SWimp_Shutdown(void)
Definition: rw_imp.c:359
width
GLint GLsizei width
Definition: qgl_win.c:115
r_notexture_buffer
byte r_notexture_buffer[1024]
Definition: r_main.c:189
mnode_s::children
struct mnode_s * children[2]
Definition: r_model.h:135
CONTENTS_SOLID
#define CONTENTS_SOLID
Definition: qfiles.h:333
xcenter
float xcenter
Definition: r_main.c:75
r_surfsonstack
qboolean r_surfsonstack
Definition: r_main.c:60
entity_s::flags
int flags
Definition: ref.h:76
R_DrawSolidClippedSubmodelPolygons
void R_DrawSolidClippedSubmodelPolygons(model_t *pmodel, mnode_t *topnode)
Definition: r_bsp.c:336
vid_gamma
cvar_t * vid_gamma
Definition: r_main.c:137
dp_time2
float dp_time2
Definition: r_main.c:106
refexport_t::AppActivate
void(* AppActivate)(qboolean activate)
Definition: ref.h:211
currententity
entity_t * currententity
Definition: r_bsp.c:28
r_time1
float r_time1
Definition: r_main.c:48
r_local.h
oldrefdef_t::yOrigin
float yOrigin
Definition: r_local.h:130
viddef_t
Definition: vid.h:27
cvar_s
Definition: q_shared.h:317
mod_brush
@ mod_brush
Definition: r_model.h:169
r_notexture_mip
image_t * r_notexture_mip
Definition: r_main.c:104
intensity
cvar_t * intensity
Definition: gl_image.c:30
mleaf_s
Definition: r_model.h:143
d_zwidth
unsigned int d_zwidth
Definition: r_main.c:184
vpn
vec3_t vpn
Definition: r_main.c:67
refexport_t::EndRegistration
void(* EndRegistration)(void)
Definition: ref.h:180
r_drawentities
cvar_t * r_drawentities
Definition: r_main.c:127
vup
vec3_t vup
Definition: r_main.c:66
refexport_t::EndFrame
void(* EndFrame)(void)
Definition: ref.h:209
SWimp_SetPalette
void SWimp_SetPalette(const unsigned char *palette)
Definition: rw_imp.c:333
j
GLint j
Definition: qgl_win.c:150
D_WarpScreen
void D_WarpScreen(void)
Definition: r_scan.c:42
Draw_GetPalette
void Draw_GetPalette(void)
Definition: r_main.c:1326
r_frustum_indexes
int r_frustum_indexes[4 *6]
Definition: r_main.c:99
R_Init
int R_Init(void *hInstance, void *wndProc)
Definition: r_main.c:300
de_time2
float de_time2
Definition: r_main.c:107
r_dspeeds
cvar_t * r_dspeeds
Definition: r_main.c:128
Mod_FreeAll
void Mod_FreeAll(void)
Definition: r_model.c:1250
sw_maxedges
cvar_t * sw_maxedges
Definition: r_main.c:117
image_t
struct image_s image_t
r_refdef
oldrefdef_t r_refdef
Definition: r_main.c:74
R_EdgeDrawing
void R_EdgeDrawing(void)
Definition: r_main.c:853
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: q_shared.c:93
yscale
float yscale
Definition: r_main.c:76
r_numallocatededges
int r_numallocatededges
Definition: r_main.c:49
RF_BEAM
#define RF_BEAM
Definition: q_shared.h:620
r_framecount
int r_framecount
Definition: r_main.c:91
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:228
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:743
R_SetLightLevel
void R_SetLightLevel(void)
Definition: r_main.c:970
mtexinfo_s::image
image_t * image
Definition: r_model.h:87
refexport_t::DrawFadeScreen
void(* DrawFadeScreen)(void)
Definition: ref.h:199
r_polycount
int r_polycount
Definition: r_main.c:94
bbextentt
fixed16_t bbextentt
Definition: r_main.c:177
RDF_NOWORLDMODEL
#define RDF_NOWORLDMODEL
Definition: q_shared.h:646
mnode_s::plane
mplane_t * plane
Definition: r_model.h:134
Draw_Fill
#define Draw_Fill
Definition: qmenu.c:53
NUM_BEAM_SEGS
#define NUM_BEAM_SEGS
RotatedBBox
void RotatedBBox(vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t tmaxs)
Definition: r_main.c:710
Draw_FadeScreen
void Draw_FadeScreen(void)
Definition: r_draw.c:428
sw_mipcap
cvar_t * sw_mipcap
Definition: r_misc.c:26
R_DrawEntitiesOnList
void R_DrawEntitiesOnList(void)
Definition: r_main.c:513
r_speeds
cvar_t * r_speeds
Definition: r_main.c:133
D_FlushCaches
void D_FlushCaches(void)
Definition: r_surf.c:418
SWimp_EndFrame
void SWimp_EndFrame(void)
Definition: rw_imp.c:176
xscaleshrink
float xscaleshrink
Definition: r_main.c:78
r_edges
edge_t * r_edges
Definition: r_edge.c:49
auxedges
edge_t * auxedges
Definition: r_edge.c:48
Draw_InitLocal
void Draw_InitLocal(void)
Definition: r_draw.c:58
numleafs
int numleafs
Definition: cmodel.c:77
MINEDGES
#define MINEDGES
Definition: r_local.h:197
entity_s::alpha
float alpha
Definition: ref.h:73
viddef_t::rowbytes
int rowbytes
Definition: r_local.h:91
vid_fullscreen
cvar_t * vid_fullscreen
Definition: r_main.c:136
r
GLdouble GLdouble r
Definition: qgl_win.c:336
dvis_t::numclusters
int numclusters
Definition: qfiles.h:465
rw_time2
float rw_time2
Definition: r_main.c:106
db_time2
float db_time2
Definition: r_main.c:106
r_maxedgesseen
int r_maxedgesseen
Definition: r_main.c:59
image_s::height
int height
Definition: r_local.h:69
R_InitTextures
void R_InitTextures(void)
Definition: r_main.c:196
refimport_t
Definition: ref.h:218
model_s::type
modtype_t type
Definition: r_model.h:177
clipplane_s::leftedge
byte leftedge
Definition: r_local.h:354
r_screenwidth
int r_screenwidth
Definition: r_main.c:81
refimport_t::Cmd_AddCommand
void(* Cmd_AddCommand)(char *name, void(*cmd)(void))
Definition: ref.h:222
verticalFieldOfView
float verticalFieldOfView
Definition: r_main.c:83
clipplane_s::rightedge
byte rightedge
Definition: r_local.h:355
skyrotate
float skyrotate
Definition: r_main.c:32
R_PrintTimes
void R_PrintTimes(void)
Definition: r_misc.c:131
R_InitCaches
void R_InitCaches(void)
Definition: r_surf.c:379
sintable
int sintable[1280]
Definition: r_rast.c:47
forward
static vec3_t forward
Definition: p_view.c:29
R_GammaCorrectAndSetPalette
void R_GammaCorrectAndSetPalette(const unsigned char *palette)
Definition: r_main.c:1160
rserr_invalid_mode
@ rserr_invalid_mode
Definition: r_local.h:102
PerpendicularVector
void PerpendicularVector(vec3_t dst, const vec3_t src)
Definition: q_shared.c:152
d_tdivzstepv
float d_tdivzstepv
Definition: r_main.c:174
bbextents
fixed16_t bbextents
Definition: r_main.c:177
model_s::leafs
mleaf_t * leafs
Definition: r_model.h:205
R_RotateBmodel
void R_RotateBmodel(void)
Definition: r_bsp.c:75
model_s::nodes
mnode_t * nodes
Definition: r_model.h:215
R_DrawParticles
void R_DrawParticles(void)
Definition: r_part.c:596
model_s::mins
vec3_t mins
Definition: r_model.h:185
mleaf_s::cluster
int cluster
Definition: r_model.h:154
pixel_t
unsigned char pixel_t
Definition: r_local.h:78
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:220
se_time1
float se_time1
Definition: r_main.c:107
screenedge
mplane_t screenedge[4]
Definition: r_main.c:86
xscale
float xscale
Definition: r_main.c:76
R_PrintAliasStats
void R_PrintAliasStats(void)
Definition: r_misc.c:175
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:155
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:309
r_worldmodel
model_t * r_worldmodel
Definition: r_main.c:39
refexport_t
Definition: ref.h:151
AMP
#define AMP
Definition: r_local.h:231
cacheblock
pixel_t * cacheblock
Definition: r_main.c:179
MINSURFACES
#define MINSURFACES
Definition: r_local.h:199
r_clipflags
int r_clipflags
Definition: r_main.c:61
cvar_s::value
float value
Definition: q_shared.h:324
r_worldentity
entity_t r_worldentity
Definition: r_main.c:29
Draw_TileClear
void Draw_TileClear(int x, int y, int w, int h, char *name)
Definition: r_draw.c:345
base_vright
vec3_t base_vright
Definition: r_main.c:68
R_UnRegister
void R_UnRegister(void)
Definition: r_main.c:288
NUMSTACKEDGES
#define NUMSTACKEDGES
Definition: r_local.h:196
XCENTERING
#define XCENTERING
Definition: r_local.h:215
Mod_Init
void Mod_Init(void)
Definition: r_model.c:78
refdef_t::blend
float blend[4]
Definition: ref.h:126
VectorNormalize
vec_t VectorNormalize(vec3_t v)
Definition: q_shared.c:681
refexport_t::DrawGetPicSize
void(* DrawGetPicSize)(int *w, int *h, char *name)
Definition: ref.h:195
NULL
#define NULL
Definition: q_shared.h:60
WARP_WIDTH
#define WARP_WIDTH
Definition: r_local.h:174
cachewidth
int cachewidth
Definition: r_main.c:180
refexport_t::CinematicSetPalette
void(* CinematicSetPalette)(const unsigned char *palette)
Definition: ref.h:207
r_viewcluster
int r_viewcluster
Definition: r_main.c:102
SWimp_SetMode
rserr_t SWimp_SetMode(int *pwidth, int *pheight, int mode, qboolean fullscreen)
Definition: rw_imp.c:266
surface_p
surf_t * surface_p
Definition: r_edge.c:51
r_viewlighting
alight_t r_viewlighting
Definition: r_main.c:47
image_s::pixels
byte * pixels[4]
Definition: r_local.h:72
image_s::width
int width
Definition: r_local.h:69
se_time2
float se_time2
Definition: r_main.c:107
R_DrawNullModel
void R_DrawNullModel(void)
Definition: r_main.c:504
dp_time1
float dp_time1
Definition: r_main.c:106
refexport_t::DrawPic
void(* DrawPic)(int x, int y, char *name)
Definition: ref.h:196
alpha
GLfloat GLfloat GLfloat alpha
Definition: qgl_win.c:74
R_CinematicSetPalette
void R_CinematicSetPalette(const unsigned char *palette)
Definition: r_main.c:1177
refexport_t::RegisterModel
struct model_s *(* RegisterModel)(char *name)
Definition: ref.h:176
AMP2
#define AMP2
Definition: r_local.h:232
blanktable
int blanktable[1280]
Definition: r_rast.c:49
d_pzbuffer
short * d_pzbuffer
Definition: r_main.c:182
r_dowarp
qboolean r_dowarp
Definition: r_main.c:54
name
cvar_t * name
Definition: cl_main.c:94
REF_VERSION
#define REF_VERSION
Definition: r_local.h:31
WARP_HEIGHT
#define WARP_HEIGHT
Definition: r_local.h:175
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:735
refexport_t::BeginRegistration
void(* BeginRegistration)(char *map)
Definition: ref.h:175
mod_sprite
@ mod_sprite
Definition: r_model.h:169
swstate_s
Definition: r_local.h:817
swstate_s::prev_mode
int prev_mode
Definition: r_local.h:820
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:157
R_RenderFrame
void R_RenderFrame(refdef_t *fd)
Definition: r_main.c:992
model_s::maxs
vec3_t maxs
Definition: r_model.h:185
swstate_s::gammatable
byte gammatable[256]
Definition: r_local.h:822
y
GLint y
Definition: qgl_win.c:115
pfrustum_indexes
int * pfrustum_indexes[4]
Definition: r_main.c:98
sw_mode
cvar_t * sw_mode
Definition: r_main.c:119
R_RegisterModel
struct model_s * R_RegisterModel(char *name)
Definition: r_model.c:1165
re
refexport_t re
Definition: vid_dll.c:31
R_IMFlatShadedQuad
void R_IMFlatShadedQuad(vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha)
Definition: r_poly.c:1230
R_FindTopnode
mnode_t * R_FindTopnode(vec3_t mins, vec3_t maxs)
Definition: r_main.c:667
entity_s::frame
int frame
Definition: ref.h:58
Draw_BuildGammaTable
void Draw_BuildGammaTable(void)
Definition: r_main.c:1217
refexport_t::BeginFrame
void(* BeginFrame)(float camera_separation)
Definition: ref.h:208
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:158
yscaleinv
float yscaleinv
Definition: r_main.c:77
R_EdgeCodeStart
void R_EdgeCodeStart(void)
d_sdivzstepv
float d_sdivzstepv
Definition: r_main.c:174
d_spanpixcount
int d_spanpixcount
Definition: r_main.c:93
sw_stipplealpha
cvar_t * sw_stipplealpha
Definition: r_main.c:122
d_zistepv
float d_zistepv
Definition: r_main.c:174
R_InitTurb
void R_InitTurb(void)
Definition: r_main.c:231
sc_base
surfcache_t * sc_base
Definition: r_local.h:753
fixed16_t
int fixed16_t
Definition: q_shared.h:132
d_tdivzstepu
float d_tdivzstepu
Definition: r_main.c:173
vec3_origin
vec3_t vec3_origin
Definition: q_shared.c:24
sw_allow_modex
cvar_t * sw_allow_modex
Definition: r_main.c:113
oldrefdef_t
Definition: r_local.h:110
refdef_t::num_entities
int num_entities
Definition: ref.h:134
r_wholepolycount
int r_wholepolycount
Definition: r_main.c:96
refexport_t::SetSky
void(* SetSky)(char *name, float rotate, vec3_t axis)
Definition: ref.h:179
r_newrefdef
refdef_t r_newrefdef
Definition: r_main.c:36
suf
char * suf[6]
Definition: r_main.c:1301
mnode_s::contents
int contents
Definition: r_model.h:126
up
static vec3_t up
Definition: p_view.c:29
R_EndRegistration
void R_EndRegistration(void)
Definition: r_model.c:1208
rserr_ok
@ rserr_ok
Definition: r_local.h:99
r_lightlevel
cvar_t * r_lightlevel
Definition: r_main.c:134
Draw_GetPicSize
void Draw_GetPicSize(int *w, int *h, char *pic)
Definition: r_draw.c:144
SWimp_Init
int SWimp_Init(void *hInstance, void *wndProc)
Definition: rw_imp.c:118
entity_s
Definition: ref.h:49
view_clipplanes
clipplane_t view_clipplanes[4]
Definition: r_rast.c:38
currentmodel
model_t * currentmodel
Definition: r_main.c:37
R_NewMap
void R_NewMap(void)
Definition: r_main.c:380
xscaleinv
float xscaleinv
Definition: r_main.c:77
NUMSTACKSURFACES
#define NUMSTACKSURFACES
Definition: r_local.h:198
alight_t
Definition: r_local.h:333
ycenter
float ycenter
Definition: r_main.c:75
CVAR_USERINFO
#define CVAR_USERINFO
Definition: q_shared.h:310
r_lefthand
cvar_t * r_lefthand
Definition: r_main.c:111
r_drawworld
cvar_t * r_drawworld
Definition: r_main.c:126
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
model_s::numleafs
int numleafs
Definition: r_model.h:204
sw_waterwarp
cvar_t * sw_waterwarp
Definition: r_main.c:124
refexport_t::Shutdown
void(* Shutdown)(void)
Definition: ref.h:160
r_dlightframecount
int r_dlightframecount
Definition: r_light.c:24
refexport_t::DrawStretchPic
void(* DrawStretchPic)(int x, int y, int w, int h, char *name)
Definition: ref.h:192
Draw_Pic
void Draw_Pic(int x, int y, char *name)
Definition: r_draw.c:253
R_ImageList_f
void R_ImageList_f(void)
Definition: r_image.c:34
sw_aliasstats
cvar_t * sw_aliasstats
Definition: r_main.c:112
d_viewbuffer
pixel_t * d_viewbuffer
Definition: r_main.c:181
R_AliasDrawModel
void R_AliasDrawModel(void)
Definition: r_alias.c:1038
R_TransformFrustum
void R_TransformFrustum(void)
Definition: r_misc.c:187
mplane_s
Definition: r_model.h:57
model_s::numnodes
int numnodes
Definition: r_model.h:213
refexport_t::api_version
int api_version
Definition: ref.h:154
R_EdgeCodeEnd
void R_EdgeCodeEnd(void)
sw_maxsurfs
cvar_t * sw_maxsurfs
Definition: r_main.c:118
refexport_t::DrawTileClear
void(* DrawTileClear)(int x, int y, int w, int h, char *name)
Definition: ref.h:197
ri
refimport_t ri
Definition: r_main.c:25
refexport_t::DrawChar
void(* DrawChar)(int x, int y, int c)
Definition: ref.h:193
R_PrintDSpeeds
void R_PrintDSpeeds(void)
Definition: r_misc.c:151
aliasxcenter
float aliasxcenter
Definition: r_main.c:79
clipplane_s::dist
float dist
Definition: r_local.h:352
R_DrawAlphaSurfaces
void R_DrawAlphaSurfaces(void)
Definition: r_poly.c:1192
Draw_FindPic
image_t * Draw_FindPic(char *name)
Definition: r_draw.c:35
rw_time1
float rw_time1
Definition: r_main.c:106
r_warpbuffer
byte r_warpbuffer[WARP_WIDTH *WARP_HEIGHT]
Definition: r_main.c:41
R_ScanEdges
void R_ScanEdges(void)
Definition: r_edge.c:635
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
R_DrawBEntitiesOnList
void R_DrawBEntitiesOnList(void)
Definition: r_main.c:768
right
GLdouble right
Definition: qgl_win.c:159
R_DrawSubmodelPolygons
void R_DrawSubmodelPolygons(model_t *pmodel, int clipflags, mnode_t *topnode)
Definition: r_bsp.c:415
refimport_t::Cvar_SetValue
void(* Cvar_SetValue)(char *name, float value)
Definition: ref.h:244
colormap
void * colormap
Definition: r_main.c:45
image_s
Definition: r_local.h:65
sw_state
swstate_t sw_state
Definition: r_main.c:43
refdef_t::viewangles
float viewangles[3]
Definition: ref.h:125
Sys_Milliseconds
int Sys_Milliseconds(void)
Definition: q_shwin.c:120
refdef_t::entities
entity_t * entities
Definition: ref.h:135
xOrigin
float xOrigin
Definition: r_main.c:84
r_viewleaf
mleaf_t * r_viewleaf
Definition: r_main.c:101
r_entorigin
vec3_t r_entorigin
Definition: r_bsp.c:31
R_MarkLeaves
void R_MarkLeaves(void)
Definition: r_main.c:432
cplane_s
Definition: q_shared.h:409
YCENTERING
#define YCENTERING
Definition: r_local.h:216
viddef_t::colormap
pixel_t * colormap
Definition: r_local.h:89
Draw_StretchPic
void Draw_StretchPic(int x, int y, int w, int h, char *name)
Definition: r_draw.c:220
Sys_Error
void Sys_Error(char *error,...)
Definition: r_main.c:1411
model_s::vertexes
mvertex_t * vertexes
Definition: r_model.h:208
STRINGER
#define STRINGER(x)
Definition: r_main.c:143
swstate_s::currentpalette
byte currentpalette[1024]
Definition: r_local.h:823
r_outofsurfaces
int r_outofsurfaces
Definition: r_main.c:51
Mod_Modellist_f
void Mod_Modellist_f(void)
Definition: r_model.c:55
viddef_t::alphamap
pixel_t * alphamap
Definition: r_local.h:90
yscaleshrink
float yscaleshrink
Definition: r_main.c:78
tadjust
fixed16_t tadjust
Definition: r_main.c:177
R_BeginFrame
void R_BeginFrame(float camera_separation)
Definition: r_main.c:1099
R_RenderWorld
void R_RenderWorld(void)
Definition: r_bsp.c:616
aliasyscale
float aliasyscale
Definition: r_main.c:79
Mod_ClusterPVS
byte * Mod_ClusterPVS(int cluster, model_t *model)
Definition: r_model.c:268
rserr_invalid_fullscreen
@ rserr_invalid_fullscreen
Definition: r_local.h:101
entity_s::oldorigin
float oldorigin[3]
Definition: ref.h:63
R_RegisterSkin
struct image_s * R_RegisterSkin(char *name)
Definition: r_image.c:564
Com_Printf
void Com_Printf(char *fmt,...)
Definition: r_main.c:1423
R_SetupFrame
void R_SetupFrame(void)
Definition: r_misc.c:426
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:127
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1236
surf_s
Definition: r_local.h:399
refexport_t::RenderFrame
void(* RenderFrame)(refdef_t *fd)
Definition: ref.h:182
surfaces
surf_t * surfaces
Definition: r_edge.c:51
r_outofedges
int r_outofedges
Definition: r_main.c:52
entity_s::angles
float angles[3]
Definition: ref.h:52
LoadPCX
void LoadPCX(char *filename, byte **pic, byte **palette, int *width, int *height)
Definition: r_image.c:87
r_fullbright
cvar_t * r_fullbright
Definition: r_main.c:129
RotatePointAroundVector
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Definition: q_shared.c:32
R_Shutdown
void R_Shutdown(void)
Definition: r_main.c:346
base_vup
vec3_t base_vup
Definition: r_main.c:66
da_time2
float da_time2
Definition: r_main.c:106
edge_s
Definition: r_local.h:421
aliasxscale
float aliasxscale
Definition: r_main.c:79
aliasycenter
float aliasycenter
Definition: r_main.c:79
it_sky
@ it_sky
Definition: r_local.h:62
d_sdivzstepu
float d_sdivzstepu
Definition: r_main.c:173