For this assignment, you will implement the scan-line polygon fill algorithm described in class and in the text. You will be given a working program that allows you to enter vertices of a polygon using mouse clicks on an area of the screen, and which draws the polygon using the OpenGL glVertex2f() routine. You will replace this routine with your own routine that, given a series of (x,y) vertices, fills the interior of the polygon defined by those vertices. Your fill routine should render GL_POINTS only, each with a pixel size of 1.0.
In addition to submitting the code of your implementation of the polygon fill algorithm, you are to turn in a written report that answers questions about your work, given at the end of this assignment description. All work must be your own. You may discuss the algorithm involved with other students at a high level, but the implementation of the algorithm must be your own work.
In the ~cs4390/OpenGL/Polygon directory, you will find the components of the program that you will modify, including a Makefile, the main file poly.c and its header, poly,h, which creates a window and contains the polygon rendering routine (drawPoly()), and the file handlers.c, which contains the code to accept mouse and keyboard input, and calls the polygon rendering routine when the window needs to be redrawn. If you copy all of the files in ~cs4390/OpenGL/Polygon to a directory in your account, and type "make" (when logged into a SGI machine), then the simple program should be compiled, producing an executable file called "poly".
When you run "poly", you should get a window on your screen

Hint: Although entering points via the mouse is cool, for testing purposes you may wish to temporarily re-write the leftMouseClick() and rightMouseClick() routines in handlers.c to use specific, hard-coded, vertices. This could be used, among other things, to test your algorithm for the special case of two adjacent polygons. You will not be turning in your handlers.c code, so be sure that your program works correctly with the original handlers.c code before submitting your program.
To complete this assignment, you will need to replace the glVertex2f() routine in the drawPoly() function in poly.c with a call to your own routine that uses points and your scan-line polygon fill algorithm to render the interior of the polygon. You should include your own code in the poly.c file, which you should turn in by sending it via email to Drew (drew@cc.gatech.edu). You should not send any other program file to Drew.
Your submission will be graded on:

Note that your code must compile and run correctly on an SGI machine in the SGI lab. If your program cannot be compiled and run, then you will not receive any credit for the assignment.
Written answers to these questions about your implementation of the scan-line polygon fill algorithm should be emailed (separately from the poly.c file) to Drew by the due date and time.
1)The polygon fill algorithm described in the text mentions four special cases that must be addressed to avoid drawing pixels multiple times. How does your program address each of these issues?
2)Describe your algorithm for tracking the x coordinate of edges for all line slopes. Code or pseudo code is ok as long as you explain why it works.
For extra credit, allow the user to switch between a solid polygon and a pattern-filled polygon by pressing the `p' key. This will require augmenting your scan-line algorithm to deal with patterns, where a solid polygon is the special case of a solid pattern, and adding a routine that responds to the `p' key by switch the pattern from solid to something else. You should define in your code a default, non-solid pattern, and clearly describe in the documentation what that pattern will look like. If you want to get fancy, you could read new patterns from a file, if it exists. In this case, clearly define in the documentation how the pattern file is formatted.
If you decide to implement the pattern fill feature for extra credit, you will need to send in your handlers.c file as well as the poly.c file. You may send them in the same email message, or separately, as long as you clearly state that you have done the extra credit assignment and Drew should expect 2 files, not just 1.