Assignment 3 due by 2/25/13
Scan Converting and Clipping Polygons: [150 points]
You are to write a program that does the following:
· Allows a user to enter in a set of polygons
· Scan Converts the polygons
· Allows a user to enter in a clipping rectangle
· Clips the polygons to that rectangle, and displays the clipped portions.
Here are the details of what you should do:
· Skeleton code is provided on the class website that does the following:
o Provides a 2D array for you to set color values of
o Displays that 2D array.
That is, you will set the individual pixel values, then call a function that displays those to the screen. You will not be using the OpenGL polygon commands.
· To draw polygons, the user should specify points using the left mouse button. Each point where the user presses down will give the next point (in order) on the polygon. The final point in the polygon will be specified by pressing the right mouse button. So, a triangle would be described by two left clicks and one right click. The user may define up to 10 polygons, each with at most 10 vertices (before clipping).
· The polygon should be scan-converted. Each polygon should be drawn in a different color. You should use an active edge table/list approach for this.
· To clip, the user should press the ‘C’ key. Once this key has been pressed, no more polygons can be entered.
· The user should specify the clipping region by clicking and dragging (with the left mouse button) a rectangle in the window. One corner of the rectangle is specified by where the button is pushed down, the opposite corner by where it is released. The clipping rectangle should be highlighted (i.e. the 4 edges of the rectangle drawn) as it is being dragged (all the polygons currently being displayed should still be shown).
· Once the rectangle has been set, the polygons should be clipped, and the clipped results displayed. You should not use scissoring, and will lose significant points if you do so.
· The user should be allowed to change the clip region as many times as desired. In each case, the original polygons entered should be used for clipping – not the already-clipped polygons.
· You may use a polygon clipping algorithm that leaves extraneous edges for concave polygons being clipped.
· Note that because you are scan converting everything onscreen over and over, do not be surprised if your program is a bit slow.
 Capturing user polygon input correctly
 Scan converting input polygons
 Different Color for each scanned polygon
 Mode transition to clip mode
 Clip rectangle capture and scan conversion as click and drag
 Clipping of polygons and scan conversion of clipped polygons