Project #0
Window Wonderland.
Due on-campus: Monday Feb 24th; For NTU/ VIP: 2 weeks or so after receipt.
Phase 1: (Do this in one week, by Wed. Sept.29 - but you nned
not hand in anything separate for this phase):
Obtain the Sample OpenGL application hlPolys.cpp
here, and get it running on your system. (You might also try the enhanced
version, hlPolys2.cpp,
that uses the GLUI and does the gingerbread man.) Adjust it so that you
can
reshape the window and neither clip nor distort a polyline drawing:
(i.e. a reshape event alters the viewport used by OpenGL to match the aspect
ratio of the drawing.)
Phase 2: Write an application that supports at least the following functionality.
At start-up a screen window is opened, showing a large "drawing area", with four small icons at the bottom. These icons are miniature versions of three "polyline figures" as described below, and one procedural figure.
The user interacts with the application using both the mouse and keyboard.
The main events, and their responses:
1). Event: The mouse is clicked inside one of the icons. Response: The figure associated with the icon becomes the "current object"; the current object is drawn in the drawing area, as large as possible with no distortion. (The drawing area is not erased by this action, so the new figure is drawn over whatever is currently in the drawing area.)
2). Event: The mouse is clicked two times inside the drawing area to specify an aligned rectangle R. Response: The drawing area is erased; the current object and rectangle R are redrawn; the portion of the figure that lies in R is drawn, expanded to as large a size as fits inside the drawing area without distortion. (If the user only clicks once before doing some other action such as pressing a key or clicking outside the drawing area, the first click is forgotten.)
3). Event: The user reshapes the screen window by dragging the lower right corner with the mouse. Response: The window is erased and the current object is redrawn as large as possible in the new drawing area (without distortion, of course).
4). Event: A key is pressed:
'e': Response: the drawing area is erased; the icons are redrawn.
'n': Response: the user is pormpted to type a new value for numTileColumns, the number of columns for the tiling. (Default number of columns = 6). The display doesn't change.
't': Response: The drawing area is tiled with non-distorted copies of the current object, scaled so that there are numTileColumns columns, and as many rows as fit vertically in the drawing area.(If the bottom row of tiles doesn't fit, leave it undrawn.)
esc: Response: The program terminates.
Discussion.
Hand in:
1. Brief instructions (hard copy) on how to use your program.
2. A complete listing (on paper) of the program code, with proper documentation.
Highlight features you want to draw to our attention.
3. A diskette containing your source code and all GRS data files your
program uses.
4. For PC users, put the executable file on the diskette, so
that your program runs by just double clicking on it. (For on-campus unix/XWindows
users: come to my office and demonstrate your program working. For VIP/NTU
unix/Xwindows users, we will work out the details by email.)
Note to NTU/VIP students: Please do not email or FAX in your
projects. Send in paper version and diskette by surface mail.