CS312 Assignment 1:  2D drawing and event processing

Due: Thursday, Sep 8, 2016 (by the end of day)

Canvas [100pts]

Write a program that simulates a 2D canvas and draws various 2D shapes. This is an individual assignment.

The program draws in the following mode:

In addition, your program should accept the following commands:

Copy the executable hw1-mac or hw1-linux from /home/dxu/handouts/cs312 to your home directory, and run it to get and idea how this program behaves.

Please read the notes on asssignments here and follow instructions for submissions.

Additional requirements/hint

  1. Display a rubberband (dotted moving line following the mouse point) when mouse button is held down during appropriate time of drawing.
  2. Use a linked list to keep track of all your shapes. If using C, use a generic linked list with void*, if using C++, make sure you set up the classes right for STL list. Do not use arrays.
  3. Keep track of all shapes, and be careful to draw the shapes from back to front to show correct overlapping, i.e. oldest shapes should be drawn first.
  4. When clearing, you should make sure that you clean up memory also. That is, delete all current shapes and avoid any memory leaks!
  5. Circles are not part of the GL basic primitives. You can draw circles by dividing a circle into a certain number of slices (triangles), i.e. use GL_TRIANGLE_FAN.
  6. When in polygon mode, click of right mouse button will indicate the end of vertices for the current polygon. Consider how you can display non-convex polygons correctly, there is no easy solution.