home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quake_src / r_edge.c < prev    next >
C/C++ Source or Header  |  2000-06-17  |  17KB  |  763 lines

  1. /*
  2. Copyright (C) 1996-1997 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_edge.c
  21.  
  22. #include "quakedef.h"
  23. #include "r_local.h"
  24.  
  25. #if 0
  26. // FIXME
  27. the complex cases add new polys on most lines, so dont optimize for keeping them the same
  28. have multiple free span lists to try to get better coherence?
  29. low depth complexity -- 1 to 3 or so
  30.  
  31. this breaks spans at every edge, even hidden ones (bad)
  32.  
  33. have a sentinal at both ends?
  34. #endif
  35.  
  36.  
  37. edge_t  *auxedges;
  38. edge_t  *r_edges, *edge_p, *edge_max;
  39.  
  40. surf_t  *surfaces, *surface_p, *surf_max;
  41.  
  42. // surfaces are generated in back to front order by the bsp, so if a surf
  43. // pointer is greater than another one, it should be drawn in front
  44. // surfaces[1] is the background, and is used as the active surface stack
  45.  
  46. edge_t  *newedges[MAXHEIGHT];
  47. edge_t  *removeedges[MAXHEIGHT];
  48.  
  49. espan_t *span_p, *max_span_p;
  50.  
  51. int   r_currentkey;
  52.  
  53. extern  int screenwidth;
  54.  
  55. int current_iv;
  56.  
  57. int edge_head_u_shift20, edge_tail_u_shift20;
  58.  
  59. static void (*pdrawfunc)(void);
  60.  
  61. edge_t  edge_head;
  62. edge_t  edge_tail;
  63. edge_t  edge_aftertail;
  64. edge_t  edge_sentinel;
  65.  
  66. float fv;
  67.  
  68. void R_GenerateSpans (void);
  69. void R_GenerateSpansBackward (void);
  70.  
  71. void R_LeadingEdge (edge_t *edge);
  72. void R_LeadingEdgeBackwards (edge_t *edge);
  73. void R_TrailingEdge (surf_t *surf, edge_t *edge);
  74.  
  75.  
  76. //=============================================================================
  77.  
  78.  
  79. /*
  80. ==============
  81. R_DrawCulledPolys
  82. ==============
  83. */
  84. void R_DrawCulledPolys (void)
  85. {
  86.   surf_t      *s;
  87.   msurface_t    *pface;
  88.  
  89.   currententity = &cl_entities[0];
  90.  
  91.   if (r_worldpolysbacktofront)
  92.   {
  93.     for (s=surface_p-1 ; s>&surfaces[1] ; s--)
  94.     {
  95.       if (!s->spans)
  96.         continue;
  97.  
  98.       if (!(s->flags & SURF_DRAWBACKGROUND))
  99.       {
  100.         pface = (msurface_t *)s->data;
  101.         R_RenderPoly (pface, 15);
  102.       }
  103.     }
  104.   }
  105.   else
  106.   {
  107.     for (s = &surfaces[1] ; s<surface_p ; s++)
  108.     {
  109.       if (!s->spans)
  110.         continue;
  111.  
  112.       if (!(s->flags & SURF_DRAWBACKGROUND))
  113.       {
  114.         pface = (msurface_t *)s->data;
  115.         R_RenderPoly (pface, 15);
  116.       }
  117.     }
  118.   }
  119. }
  120.  
  121.  
  122. /*
  123. ==============
  124. R_BeginEdgeFrame
  125. ==============
  126. */
  127. void R_BeginEdgeFrame (void)
  128. {
  129.   int   v;
  130.  
  131.   edge_p = r_edges;
  132.   edge_max = &r_edges[r_numallocatededges];
  133.  
  134.   surface_p = &surfaces[2]; // background is surface 1,
  135.                 //  surface 0 is a dummy
  136.   surfaces[1].spans = NULL; // no background spans yet
  137.   surfaces[1].flags = SURF_DRAWBACKGROUND;
  138.  
  139. // put the background behind everything in the world
  140.   if (r_draworder.value)
  141.   {
  142.     pdrawfunc = R_GenerateSpansBackward;
  143.     surfaces[1].key = 0;
  144.     r_currentkey = 1;
  145.   }
  146.   else
  147.   {
  148.     pdrawfunc = R_GenerateSpans;
  149.     surfaces[1].key = 0x7FFFFFFF;
  150.     r_currentkey = 0;
  151.   }
  152.  
  153. // FIXME: set with memset
  154.   for (v=r_refdef.vrect.y ; v<r_refdef.vrectbottom ; v++)
  155.   {
  156.     newedges[v] = removeedges[v] = NULL;
  157.   }
  158. }
  159.  
  160.  
  161. #if !id386 && !defined(M68KASM) && !defined(PPCASM)
  162. /*
  163. ==============
  164. R_InsertNewEdges
  165.  
  166. Adds the edges in the linked list edgestoadd, adding them to the edges in the
  167. linked list edgelist.  edgestoadd is assumed to be sorted on u, and non-empty (this is actually newedges[v]).  edgelist is assumed to be sorted on u, with a
  168. sentinel at the end (actually, this is the active edge table starting at
  169. edge_head.next).
  170. ==============
  171. */
  172. void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist)
  173. {
  174.   edge_t  *next_edge;
  175.  
  176.   do
  177.   {
  178.     next_edge = edgestoadd->next;
  179. edgesearch:
  180.     if (edgelist->u >= edgestoadd->u)
  181.       goto addedge;
  182.     edgelist=edgelist->next;
  183.     if (edgelist->u >= edgestoadd->u)
  184.       goto addedge;
  185.     edgelist=edgelist->next;
  186.     if (edgelist->u >= edgestoadd->u)
  187.       goto addedge;
  188.     edgelist=edgelist->next;
  189.     if (edgelist->u >= edgestoadd->u)
  190.       goto addedge;
  191.     edgelist=edgelist->next;
  192.     goto edgesearch;
  193.  
  194.   // insert edgestoadd before edgelist
  195. addedge:
  196.     edgestoadd->next = edgelist;
  197.     edgestoadd->prev = edgelist->prev;
  198.     edgelist->prev->next = edgestoadd;
  199.     edgelist->prev = edgestoadd;
  200.   } while ((edgestoadd = next_edge) != NULL);
  201. }
  202.   
  203.  
  204. /*
  205. ==============
  206. R_RemoveEdges
  207. ==============
  208. */
  209. void R_RemoveEdges (edge_t *pedge)
  210. {
  211.  
  212.   do
  213.   {
  214.     pedge->next->prev = pedge->prev;
  215.     pedge->prev->next = pedge->next;
  216.   } while ((pedge = pedge->nextremove) != NULL);
  217. }
  218.  
  219.  
  220. /*
  221. ==============
  222. R_StepActiveU
  223. ==============
  224. */
  225. void R_StepActiveU (edge_t *pedge)
  226. {
  227.   edge_t    *pnext_edge, *pwedge;
  228.  
  229.   while (1)
  230.   {
  231. nextedge:
  232.     pedge->u += pedge->u_step;
  233.     if (pedge->u < pedge->prev->u)
  234.       goto pushback;
  235.     pedge = pedge->next;
  236.       
  237.     pedge->u += pedge->u_step;
  238.     if (pedge->u < pedge->prev->u)
  239.       goto pushback;
  240.     pedge = pedge->next;
  241.       
  242.     pedge->u += pedge->u_step;
  243.     if (pedge->u < pedge->prev->u)
  244.       goto pushback;
  245.     pedge = pedge->next;
  246.       
  247.     pedge->u += pedge->u_step;
  248.     if (pedge->u < pedge->prev->u)
  249.       goto pushback;
  250.     pedge = pedge->next;
  251.       
  252.     goto nextedge;    
  253.     
  254. pushback:
  255.     if (pedge == &edge_aftertail)
  256.       return;
  257.       
  258.   // push it back to keep it sorted   
  259.     pnext_edge = pedge->next;
  260.  
  261.   // pull the edge out of the edge list
  262.     pedge->next->prev = pedge->prev;
  263.     pedge->prev->next = pedge->next;
  264.  
  265.   // find out where the edge goes in the edge list
  266.     pwedge = pedge->prev->prev;
  267.  
  268.     while (pwedge->u > pedge->u)
  269.     {
  270.       pwedge = pwedge->prev;
  271.     }
  272.  
  273.   // put the edge back into the edge list
  274.     pedge->next = pwedge->next;
  275.     pedge->prev = pwedge;
  276.     pedge->next->prev = pedge;
  277.     pwedge->next = pedge;
  278.  
  279.     pedge = pnext_edge;
  280.     if (pedge == &edge_tail)
  281.       return;
  282.   }
  283. }
  284. #endif  // !id386/!M68KASM/!PPCASM
  285.  
  286.  
  287. /*
  288. ==============
  289. R_CleanupSpan
  290. ==============
  291. */
  292. void R_CleanupSpan ()
  293. {
  294.   surf_t  *surf;
  295.   int   iu;
  296.   espan_t *span;
  297.  
  298. // now that we've reached the right edge of the screen, we're done with any
  299. // unfinished surfaces, so emit a span for whatever's on top
  300.   surf = surfaces[1].next;
  301.   iu = edge_tail_u_shift20;
  302.   if (iu > surf->last_u)
  303.   {
  304.     span = span_p++;
  305.     span->u = surf->last_u;
  306.     span->count = iu - span->u;
  307.     span->v = current_iv;
  308.     span->pnext = surf->spans;
  309.     surf->spans = span;
  310.   }
  311.  
  312. // reset spanstate for all surfaces in the surface stack
  313.   do
  314.   {
  315.     surf->spanstate = 0;
  316.     surf = surf->next;
  317.   } while (surf != &surfaces[1]);
  318. }
  319.  
  320.  
  321. /*
  322. ==============
  323. R_LeadingEdgeBackwards
  324. ==============
  325. */
  326. void R_LeadingEdgeBackwards (edge_t *edge)
  327. {
  328.   espan_t     *span;
  329.   surf_t      *surf, *surf2;
  330.   int       iu;
  331.  
  332. // it's adding a new surface in, so find the correct place
  333.   surf = &surfaces[edge->surfs[1]];
  334.  
  335. // don't start a span if this is an inverted span, with the end
  336. // edge preceding the start edge (that is, we've already seen the
  337. // end edge)
  338.   if (++surf->spanstate == 1)
  339.   {
  340.     surf2 = surfaces[1].next;
  341.  
  342.     if (surf->key > surf2->key)
  343.       goto newtop;
  344.  
  345.   // if it's two surfaces on the same plane, the one that's already
  346.   // active is in front, so keep going unless it's a bmodel
  347.     if (surf->insubmodel && (surf->key == surf2->key))
  348.     {
  349.     // must be two bmodels in the same leaf; don't care, because they'll
  350.     // never be farthest anyway
  351.       goto newtop;
  352.     }
  353.  
  354. continue_search:
  355.  
  356.     do
  357.     {
  358.       surf2 = surf2->next;
  359.     } while (surf->key < surf2->key);
  360.  
  361.     if (surf->key == surf2->key)
  362.     {
  363.     // if it's two surfaces on the same plane, the one that's already
  364.     // active is in front, so keep going unless it's a bmodel
  365.       if (!surf->insubmodel)
  366.         goto continue_search;
  367.  
  368.     // must be two bmodels in the same leaf; don't care which is really
  369.     // in front, because they'll never be farthest anyway
  370.     }
  371.  
  372.     goto gotposition;
  373.  
  374. newtop:
  375.   // emit a span (obscures current top)
  376.     iu = edge->u >> 20;
  377.  
  378.     if (iu > surf2->last_u)
  379.     {
  380.       span = span_p++;
  381.       span->u = surf2->last_u;
  382.       span->count = iu - span->u;
  383.       span->v = current_iv;
  384.       span->pnext = surf2->spans;
  385.       surf2->spans = span;
  386.     }
  387.  
  388.     // set last_u on the new span
  389.     surf->last_u = iu;
  390.         
  391. gotposition:
  392.   // insert before surf2
  393.     surf->next = surf2;
  394.     surf->prev = surf2->prev;
  395.     surf2->prev->next = surf;
  396.     surf2->prev = surf;
  397.   }
  398. }
  399.  
  400.  
  401. /*
  402. ==============
  403. R_TrailingEdge
  404. ==============
  405. */
  406. void R_TrailingEdge (surf_t *surf, edge_t *edge)
  407. {
  408.   espan_t     *span;
  409.   int       iu;
  410.  
  411. // don't generate a span if this is an inverted span, with the end
  412. // edge preceding the start edge (that is, we haven't seen the
  413. // start edge yet)
  414.   if (--surf->spanstate == 0)
  415.   {
  416.     if (surf->insubmodel)
  417.       r_bmodelactive--;
  418.  
  419.     if (surf == surfaces[1].next)
  420.     {
  421.     // emit a span (current top going away)
  422.       iu = edge->u >> 20;
  423.       if (iu > surf->last_u)
  424.       {
  425.         span = span_p++;
  426.         span->u = surf->last_u;
  427.         span->count = iu - span->u;
  428.         span->v = current_iv;
  429.         span->pnext = surf->spans;
  430.         surf->spans = span;
  431.       }
  432.  
  433.     // set last_u on the surface below
  434.       surf->next->last_u = iu;
  435.     }
  436.  
  437.     surf->prev->next = surf->next;
  438.     surf->next->prev = surf->prev;
  439.   }
  440. }
  441.  
  442.  
  443. #if !id386 && !defined(M68KASM) && !defined(PPCASM)
  444. /*
  445. ==============
  446. R_LeadingEdge
  447. ==============
  448. */
  449. void R_LeadingEdge (edge_t *edge)
  450. {
  451.   espan_t     *span;
  452.   surf_t      *surf, *surf2;
  453.   int       iu;
  454.   double      fu, newzi, testzi, newzitop, newzibottom;
  455.  
  456.   if (edge->surfs[1])
  457.   {
  458.   // it's adding a new surface in, so find the correct place
  459.     surf = &surfaces[edge->surfs[1]];
  460.  
  461.   // don't start a span if this is an inverted span, with the end
  462.   // edge preceding the start edge (that is, we've already seen the
  463.   // end edge)
  464.     if (++surf->spanstate == 1)
  465.     {
  466.       if (surf->insubmodel)
  467.         r_bmodelactive++;
  468.  
  469.       surf2 = surfaces[1].next;
  470.  
  471.       if (surf->key < surf2->key)
  472.         goto newtop;
  473.  
  474.     // if it's two surfaces on the same plane, the one that's already
  475.     // active is in front, so keep going unless it's a bmodel
  476.       if (surf->insubmodel && (surf->key == surf2->key))
  477.       {
  478.       // must be two bmodels in the same leaf; sort on 1/z
  479.         fu = (float)(edge->u - 0xFFFFF) * (1.0 / 0x100000);
  480.         newzi = surf->d_ziorigin + fv*surf->d_zistepv +
  481.             fu*surf->d_zistepu;
  482.         newzibottom = newzi * 0.99;
  483.  
  484.         testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
  485.             fu*surf2->d_zistepu;
  486.  
  487.         if (newzibottom >= testzi)
  488.         {
  489.           goto newtop;
  490.         }
  491.  
  492.         newzitop = newzi * 1.01;
  493.         if (newzitop >= testzi)
  494.         {
  495.           if (surf->d_zistepu >= surf2->d_zistepu)
  496.           {
  497.             goto newtop;
  498.           }
  499.         }
  500.       }
  501.  
  502. continue_search:
  503.  
  504.       do
  505.       {
  506.         surf2 = surf2->next;
  507.       } while (surf->key > surf2->key);
  508.  
  509.       if (surf->key == surf2->key)
  510.       {
  511.       // if it's two surfaces on the same plane, the one that's already
  512.       // active is in front, so keep going unless it's a bmodel
  513.         if (!surf->insubmodel)
  514.           goto continue_search;
  515.  
  516.       // must be two bmodels in the same leaf; sort on 1/z
  517.         fu = (float)(edge->u - 0xFFFFF) * (1.0 / 0x100000);
  518.         newzi = surf->d_ziorigin + fv*surf->d_zistepv +
  519.             fu*surf->d_zistepu;
  520.         newzibottom = newzi * 0.99;
  521.  
  522.         testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
  523.             fu*surf2->d_zistepu;
  524.  
  525.         if (newzibottom >= testzi)
  526.         {
  527.           goto gotposition;
  528.         }
  529.  
  530.         newzitop = newzi * 1.01;
  531.         if (newzitop >= testzi)
  532.         {
  533.           if (surf->d_zistepu >= surf2->d_zistepu)
  534.           {
  535.             goto gotposition;
  536.           }
  537.         }
  538.  
  539.         goto continue_search;
  540.       }
  541.  
  542.       goto gotposition;
  543.  
  544. newtop:
  545.     // emit a span (obscures current top)
  546.       iu = edge->u >> 20;
  547.  
  548.       if (iu > surf2->last_u)
  549.       {
  550.         span = span_p++;
  551.         span->u = surf2->last_u;
  552.         span->count = iu - span->u;
  553.         span->v = current_iv;
  554.         span->pnext = surf2->spans;
  555.         surf2->spans = span;
  556.       }
  557.  
  558.       // set last_u on the new span
  559.       surf->last_u = iu;
  560.         
  561. gotposition:
  562.     // insert before surf2
  563.       surf->next = surf2;
  564.       surf->prev = surf2->prev;
  565.       surf2->prev->next = surf;
  566.       surf2->prev = surf;
  567.     }
  568.   }
  569. }
  570.  
  571.  
  572. /*
  573. ==============
  574. R_GenerateSpans
  575. ==============
  576. */
  577. void R_GenerateSpans (void)
  578. {
  579.   edge_t      *edge;
  580.   surf_t      *surf;
  581.  
  582.   r_bmodelactive = 0;
  583.  
  584. // clear active surfaces to just the background surface
  585.   surfaces[1].next = surfaces[1].prev = &surfaces[1];
  586.   surfaces[1].last_u = edge_head_u_shift20;
  587.  
  588. // generate spans
  589.   for (edge=edge_head.next ; edge != &edge_tail; edge=edge->next)
  590.   {     
  591.     if (edge->surfs[0])
  592.     {
  593.     // it has a left surface, so a surface is going away for this span
  594.       surf = &surfaces[edge->surfs[0]];
  595.  
  596.       R_TrailingEdge (surf, edge);
  597.  
  598.       if (!edge->surfs[1])
  599.         continue;
  600.     }
  601.  
  602.     R_LeadingEdge (edge);
  603.   }
  604.  
  605.   R_CleanupSpan ();
  606. }
  607. #endif  // !id386/!M68KASM/!PPCASM
  608.  
  609.  
  610. /*
  611. ==============
  612. R_GenerateSpansBackward
  613. ==============
  614. */
  615. void R_GenerateSpansBackward (void)
  616. {
  617.   edge_t      *edge;
  618.  
  619.   r_bmodelactive = 0;
  620.  
  621. // clear active surfaces to just the background surface
  622.   surfaces[1].next = surfaces[1].prev = &surfaces[1];
  623.   surfaces[1].last_u = edge_head_u_shift20;
  624.  
  625. // generate spans
  626.   for (edge=edge_head.next ; edge != &edge_tail; edge=edge->next)
  627.   {     
  628.     if (edge->surfs[0])
  629.       R_TrailingEdge (&surfaces[edge->surfs[0]], edge);
  630.  
  631.     if (edge->surfs[1])
  632.       R_LeadingEdgeBackwards (edge);
  633.   }
  634.  
  635.   R_CleanupSpan ();
  636. }
  637.  
  638.  
  639. /*
  640. ==============
  641. R_ScanEdges
  642.  
  643. Input: 
  644. newedges[] array
  645.   this has links to edges, which have links to surfaces
  646.  
  647. Output:
  648. Each surface has a linked list of its visible spans
  649. ==============
  650. */
  651. void R_ScanEdges (void)
  652. {
  653.   int   iv, bottom;
  654.   static byte  basespans[MAXSPANS*sizeof(espan_t)+CACHE_SIZE];  /* phx */
  655.   espan_t *basespan_p;
  656.   surf_t  *s;
  657.  
  658.   basespan_p = (espan_t *)
  659.       ((long)(basespans + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
  660.   max_span_p = &basespan_p[MAXSPANS - r_refdef.vrect.width];
  661.  
  662.   span_p = basespan_p;
  663.  
  664. // clear active edges to just the background edges around the whole screen
  665. // FIXME: most of this only needs to be set up once
  666.   edge_head.u = r_refdef.vrect.x << 20;
  667.   edge_head_u_shift20 = edge_head.u >> 20;
  668.   edge_head.u_step = 0;
  669.   edge_head.prev = NULL;
  670.   edge_head.next = &edge_tail;
  671.   edge_head.surfs[0] = 0;
  672.   edge_head.surfs[1] = 1;
  673.   
  674.   edge_tail.u = (r_refdef.vrectright << 20) + 0xFFFFF;
  675.   edge_tail_u_shift20 = edge_tail.u >> 20;
  676.   edge_tail.u_step = 0;
  677.   edge_tail.prev = &edge_head;
  678.   edge_tail.next = &edge_aftertail;
  679.   edge_tail.surfs[0] = 1;
  680.   edge_tail.surfs[1] = 0;
  681.   
  682.   edge_aftertail.u = -1;    // force a move
  683.   edge_aftertail.u_step = 0;
  684.   edge_aftertail.next = &edge_sentinel;
  685.   edge_aftertail.prev = &edge_tail;
  686.  
  687. // FIXME: do we need this now that we clamp x in r_draw.c?
  688.   edge_sentinel.u = 2000 << 24;   // make sure nothing sorts past this
  689.   edge_sentinel.prev = &edge_aftertail;
  690.  
  691. //  
  692. // process all scan lines
  693. //
  694.   bottom = r_refdef.vrectbottom - 1;
  695.  
  696.   for (iv=r_refdef.vrect.y ; iv<bottom ; iv++)
  697.   {
  698.     current_iv = iv;
  699.     fv = (float)iv;
  700.  
  701.   // mark that the head (background start) span is pre-included
  702.     surfaces[1].spanstate = 1;
  703.  
  704.     if (newedges[iv])
  705.     {
  706.       R_InsertNewEdges (newedges[iv], edge_head.next);
  707.     }
  708.  
  709.     (*pdrawfunc) ();
  710.  
  711.   // flush the span list if we can't be sure we have enough spans left for
  712.   // the next scan
  713.     if (span_p >= max_span_p)
  714.     {
  715.       VID_UnlockBuffer ();
  716.       S_ExtraUpdate (); // don't let sound get messed up if going slow
  717.       VID_LockBuffer ();
  718.     
  719.       if (r_drawculledpolys)
  720.       {
  721.         R_DrawCulledPolys ();
  722.       }
  723.       else
  724.       {
  725.         D_DrawSurfaces ();
  726.       }
  727.  
  728.     // clear the surface span pointers
  729.       for (s = &surfaces[1] ; s<surface_p ; s++)
  730.         s->spans = NULL;
  731.  
  732.       span_p = basespan_p;
  733.     }
  734.  
  735.     if (removeedges[iv])
  736.       R_RemoveEdges (removeedges[iv]);
  737.  
  738.     if (edge_head.next != &edge_tail)
  739.       R_StepActiveU (edge_head.next);
  740.   }
  741.  
  742. // do the last scan (no need to step or sort or remove on the last scan)
  743.  
  744.   current_iv = iv;
  745.   fv = (float)iv;
  746.  
  747. // mark that the head (background start) span is pre-included
  748.   surfaces[1].spanstate = 1;
  749.  
  750.   if (newedges[iv])
  751.     R_InsertNewEdges (newedges[iv], edge_head.next);
  752.  
  753.   (*pdrawfunc) ();
  754.  
  755. // draw whatever's left in the span list
  756.   if (r_drawculledpolys)
  757.     R_DrawCulledPolys ();
  758.   else
  759.     D_DrawSurfaces ();
  760. }
  761.  
  762.  
  763.