Refreshing refers to the continual redirection of the electron beam (in the CRT) back to pixel positions that are to be illuminated. This is necessary because the light emitted from the screen phosphor at these positions lasts only a short time. Without refreshing, the displayed picture would fade away in less than a second.
Two views of the scene are generated: one from the viewing position of the left eye, and the other from the viewing position of the right eye. The two views are then displayed on the monitor on alternate refresh cycles and viewed through special eyeglasses that alternately darken the left and right lenses in synchronization with the alternating displays. Thus, the left eye of the viewer sees only the left view, and the right eye sees only the right view of the scene. See page 50 in the textbook for an illustration of the technique.
Both methods set up iterative calculations to determine which of two possible pixels at each step is closest to a specified line path. The Bresenham method calculates the distance from each of these two possible pixels to the line path. The decision parameter is based on their difference: greater to or less than zero. The midpoint method selects the closest pixel by determining whether the midposition between the two pixels is above or below the line path.
Assuming the addressing scheme for the frame-buffer is set up in row-major order on a bilevel system (eg. black and white), the address of a pixel at location (x,y) is calculated as an offset from the starting address of the frame-buffer as:
If we move across a scan line, we can calculate the frame-buffer address for a pixel at location (x+1,y) by using the previous calculation for the pixel at (x,y) as:
If we move diagonally down to the next scan line, we can calculate the frame-buffer address for a pixel at location (x+1,y+1) by using the previous calculation for the pixel at (x,y) as:
glPointSize
glColor
The scan line method would be best.
Both the boundary fill and flood fill methods require a starting interior position for filling. Given only the polygon vertices for an arbitrary fill shape, it would be difficult to determine an interior point for the fill. Also, boundary fill requires a single outline color for the polygon and flood fill requires a single background color for the polygon. This implies that the polygon would need to be in the frame-buffer already. (Another problem involves 4-connected vs. 8-connected for the filling algorithm.)
The scan line method involves only intersection calculations for scan lines with the polygon edges.
| | | 2 | 0 | 0 | | | | | cos 30° | -sin 30° | 0 | | | | | sqrt(3) | -1 | 0 | | | ||
| | | 0 | 3 | 0 | | | * | | | sin 30° | cos 30° | 0 | | | = | | | 1.5 | 1.5*sqrt(3) | 0 | | |
| | | 0 | 0 | 1 | | | | | 0 | 0 | 1 | | | | | 0 | 0 | 1 | | |
General Method: The original polygon is erased by re-scan converting it in the background color. If the original polygon overlaps other objects, then the entire scene (minus the original polygon) can be reloaded into the frame-buffer. Then, each vertex of the polygon is multiplied by the above composite matrix to obtain a list of "transformed" vertices. These new vertices are used to scan convert the new polygon into the frame-buffer.
OpenGL Method: The screen is cleared to the background color using glClear. Then, any other objects are drawn. Next, the above composite matrix is loaded onto the matrix stack using glLoadMatrix. Finally, the vertices of the polygon are redrawn, and the new polygon is automatically transformed by the OpenGL matrix stack into its new position.
gluOrtho2D(Left,Right,Bottom,Top)
glViewport(xo,yo,Width,Height)
Clipping each line produces only the clipped coordinates for that line (either no coordinates or the two endpoints for the clipped line). In general, there is no informataion about the order in which the line endpoints must be connected to produce a polygon vertex list. See Figure 6-17 on page 237 in the textbook for an illustration.
The Sutherland-Hodgeman algorithm always returns a single vertex list, which results in a single "clipped" polygon. Clipping a convex polygon results in another convex polygon, so the algorithm works correctly with convex polygons. However, clipping a concave polygon may result in two or more separate polygon sections. Such a concave polygon clipped with this algorithm will have connecting lines between the "separate" polygon sections.
For an example of a concave polygon that would not be clipped correctly by the Sutherland-Hodgeman algorithm, see Figure 6-24 on page 242 in the textbook.