Different types of polygons:
A variety of polygon representations can be used, one of the most common
ones being an ordered list of references to a vertex list. This avoids
redundant storage and redundant computations. We'll also be associating
a variety of other information with vertices, such as normals, colours,
and texture coordinates.
The job of scan conversion is to shade pixels lying within a closed polygon, and to do so efficiently. The fill colour will in general depend on the lighting, texture, and visibility of the polygon being scan-converted. These will be ignored for the time being.
Let's assume that the polygon is closed and has ordered edges.
The scan conversion algorithm then works as follows:
Shortening an edge
Many intersection tests can be eliminated by taking advantage of coherence between adjacent scanlines.
o traverse edges o eliminate horizontal edges o if not local extremum, shorten upper vertex o add edge to linked-list for the scanline corresponding to the lower vertex, storing: - y_upper: last scanline to consider - x_lower: starting x coordinate for edge - 1/m: for incrementing x; compute before shortening
- y_upper: last scanline to consider - x: edge's intersection with current y) - 1/m: for incrementing xThe active edges are kept sorted by x.
o for each scanline o add edges in edge table to AEL o if AEL <> NIL o sort AEL by x o fill pixels between edge pairs o delete finished edges o update each edge's x