From: Dave Stampe-Psy+Eng <dstamp@watserv1.waterloo.edu>
Subject: Re: Defining VR : must it be so visual?
Date: Sun, 27 Oct 1991 15:07:58 GMT
Message-ID: <1991Oct27.150758.18045@watserv1.waterloo.edu>
Organization: University of Waterloo


I've had a number of requests for the fast VGA poly code.  I'm not going to
any time to work on it for a week or so, but there are certain problems that
someone else could work on that would speed up the development.  You can 
simulate what i'm doing in C, then send me the results so I can code the
assembler.  As soon as it's done, I'll post it.

The problem is this:  a good 3D poly drawer must guarantee filling of the
edge between 2 polygons, yet not write more pixels than required.  It must
"look" good on the edges (i.e not have 1 point on the top line of the
poly, and 6 points on each of the next lines:

        x              xx
    xxxxxxxx       xxxxxxxxxx
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx
   NO!              YES!

Also, it's nice if a "sliver" poly stays contiguous (although this may
not match the minimum filling requirement above):

              x             xx
         x             xxxx
     x               xx 
  NO!                YES!

Anyway, this is what the assembly code does (and it's the fastest way to 
do it on a 386)
- computes (x2-x1)/(y2-y1) slope for each side of the polygon with 16-bit
underflow
- presets left and right 32-bit registers with x1<<16
- for each line: draws a line (VERY FAST) from (left>>16,y)-(right>>16,y)
- steps by adding the slope to the left and right registers, does next line

This process can easily be emulated in C, using floating-point math.
Please use only 16-bit (int) adds, shifts, etc.  NO multiplies or divisions.

The reason why I'm posting this request is that the repetitive poly fill
method using this code is not really the way I want to do my renderer: it's
a test case.  The scan-line method I want to use doesn't have these problems,
and the graphics books I have don't address these problems.


--------------------------------------------------------------------------
| My life is Hardware,                    |                              | 
| my destiny is Software,                 |         Dave Stampe          |
| my CPU is Wetware...                    |                              | 
| Anybody got a SDB I can borrow?         | dstamp@watserv1.uwaterloo.ca |
__________________________________________________________________________
