Since you implemented your own line drawing routine in the first assignment you can now use the OpenGL version in this assignment. You may not however use any of the OpenGL matrix commands or viewport commands.
You can find a shell for the program here
Your program should be run as:
where polygon-file-name is in the same format as in the first assignment. This time, however, the coordinates of the polygon are in world-space. The polygon will be drawn as a connected series of white line segments. As in the first assignment the polygon can be concave with crossing edges.
The space should also contain a green X axis (worldspace Y=0) and Y axis (worldspace X=0.) The axis (which should be at least 1000 units long in workd-space) will allow you to see the relative movement of the polygon when its transformation matrix is altered.
You will need to maintain two transformation matrices, one for the polygon, and one for the viewport. These matrices will be controlled from the keyboard:
Once the polygon is read in, its coordinates should not change. It will only be affected through changes made to its transformation matrix. Both the axis and the polyogn will be affected by changes to the viewport transformation matrix. Initially the axis should be centered in the viewport.
To draw the scene you will need to apply the appropriate transformations to the polygon and the axis and then clip them against a viewport that is smaller than the window by 10 pixels on each side. OpenGL will automatically perform clipping at the boundary of the window but you are responsible for clipping to this smaller region (using line clipping for the axis and polygon clipping for the polygon.) As discussed in class, the polygon clipping algorithm may introduce new edges at the borders of the clipping rectangle - this is OK.
As with assignment 1, your program should be well commented and be a good example of literate programming; again it will be submitted electronically; and again be sure it can be compiled and executed with acc and Mesa on the EECS suns.
I would suggest first creating the axis, and the viewing transformation matrix so you can see if you are moving the viewport correctly. Then add in your existing code to read in the polygon and draw it; then add in the code to modify the objects's transformation matrix. Finally integrate the line clipping and polygon clipping routines.