Use the texture mapping techique demonstrated in texture.c to apply a checkerboard pattern to the back windshield of the car.
| Keystroke | Action |
|---|---|
| 1 | toggle Light 1 on / off |
| 2 | toggle Light 2 on / off |
| r | make Light 2 red |
| g | make Light 2 green |
| b | make Light 2 blue |
| w | make Light 2 white |
The lights should remain fixed while the model rotates in response to dragging the mouse.
If you didn't finish Assignment 8, choose another GLUT shape (e.g., cube, sphere, torus, etc.) The shape can be rendered as a wireframe if necessary.
If you didn't attend class and can't get the notes, you can either try searching the web for virtual trackball, or you can read Chapter 12 of the red book and try to figure out pick lists. If you choose the latter option, draw several overlapping shapes to choose from.

| Color | Function |
|---|---|
| Red and Yellow | glutSolidCube() |
| Blue and Green | glBegin(GL_POLYGON) |
| Black | glutSolidTorus() |
Another hint: use Polygon Mode GL_LINE and enable back-face culling to check that the front- and back-facing polygons have been specified in the correct order.
Download assignment8.exe and run it to experiment with the various options. Drag with the left mouse button to rotate the model, and use the right-click context menu to change rendering options.
Note that you do not need to implement either the rotation or the context menu. (We will implement the rotation next week.)
By the way -- feel free to draw a nicer car.


draw_line() function. Use Bresenham's algorithm, but note that you will need to generalize in order to handle cases where the slope is not less than 1 and (x0, y0) is not lower than and to the left of (x1, y1).

x, y, z) and view frustum defined by (left, right, bottom, top, near, far), as shown in the code. You can adjust the view with the following keys:
| Keystroke | Action |
|---|---|
z/Z |
Zoom the camera in/out |
n/N |
Move the near clip plane in the negative/positive Z direction |
f/F |
Move the far clip plane in the negative/positive z direction |
x/X |
Increase/decrease the width of the near clip plane |
y/Y |
Increase/decrease the height of the near clip plane |
q |
Quit |
The left pane shows the same scene, from a different angle. Its viewing parameters are fixed.
Your assignment is to render the camera and viewing frustum used by the view in the right pane into the scene in the left pane:

| Camera at (0, 0, 3) | Camera at (2, 2, 2) | |
|---|---|---|
| Perspective Projection | ![]() |
|
| Parallel Projection | ||
| Keystroke | Action |
|---|---|
r |
Select rotation as the current transformation |
s |
Select scaling as the current transformation |
t |
Select translation as the current transformation |
x |
As appropriate for the currently selected transformation:
|
X |
As appropriate for the currently selected transformation:
|
y |
As appropriate for the currently selected transformation:
|
Y |
As appropriate for the currently selected transformation:
|
z |
As appropriate for the currently selected transformation:
|
Z |
As appropriate for the currently selected transformation:
|
i |
Return the cube to its original position |
Rotation should be about the x, y, and z axes, not about the center of the cube. (Unless, of course, the cube is currently centered at the origin.)
Transformations should be cumulative. For example, switching to rotation from scaling should not reset the scaling factors to 1.
![]() |
![]() |
Visually, the vectors will appear to form a second set of coordinate axes which moves separately from the original one. In fact, that is the purpose of an orthonormal basis (at least in computer graphics): to define a new coordinate frame. If you are having trouble visualizing the results, download assignment2.exe to see the results.
You can download pre-compiled DLLs for use with Visual C++ from Nate Robins's GLUT for Win32 page. If you are using Dev-C++, you can download a GLUT DevPack from Nigel Stewart's page
At some point, you will need the reference documentation for the GLUT API.
To test that your programming environment is set up correctly, type in Example 1-2 from Chapter 1 of the OpenGL Programming Guide and get it running. When you have finished, submit the assignment using the procedure described in the Syllabus and confirm that you get a return receipt.
Note: there is a difference between the HTML and PDF versions of the OpenGL Programming Guide. The PDF version uses GLUT, while the HTML version uses the older "aux" library. The libraries are similar, but code written for one will not compile and run without some translation between the two APIs.