First Programming Assignment: Modifying a Paint application


Due: beginning of class, Monday 2/9/98
Last Updated: 2/1/98
Modify the existing GLUT application, paint.c (from Angel's book) to:
  1. Support "live" rubberbanding of the triangle, square and line.
  2. Eliminate (mostly) flickering of the clock.
  3. All draw actions should be modal: clicking on the rectangle box should mean that you'll be drawing rectangles until selecting a different action.
  4. Add highlighting to indicate which drawing action is currently active (i.e., are we drawing rectangles, or triangles)?
  5. Add a "selection" action. In this mode, clicking on an object causes that object to pop to the front; if it was overlaid, it should now overlay.

Rubberbanding

For rubberbanding, you probably want to use the double XOR'ing technique we discussed in class. If you want to read about how to fiddle with the bitwise logical functions in OpenGL, check out pp392-394 in Woo's book, "Blending, Dithering and Logical Operations".

Briefly, you'll want to use code the looks like this:

glEnable(GL_INDEX_LOGIC_OP) or glEnable(GL_COLOR_LOGIC_OP)
glLogicOp(GL_XOR)
.
.
.
glDisable(GL_INDEX_LOGIC_OP) or glDisable(GL_COLOR_LOGIC_OP)

The choice of ORs depends on whether you are using a color table (INDEX), or whether each pixel is storing an actual RGB value (COLOR). I belive the latter is the situation on the Sparcstations.

By the way, the default LogicOp is GL_COPY.

Object selection

Item 5 of the list is the most involved. You will need to maintain some kind of data structure to keep track of the objects currently displayed and their bounding boxes. The definition of the bounding boxes will have to be integrated with the drawing operations somehow. You'll need to keep track of color, too.

Extra Credit: for an extra third of a grade, make selection conform exactly to the polygons' boundary. For lines, being within two pixels of the line should be sufficient.

DEMOS: You will demonstrate your programs to me to show that they work correctly. These demonstrations may be videotaped. (We collect the best efforts for use in other classes.).