This is a simple project to help familiarize you with our graphics hardware and software. You will learn how to edit and compile programs on our workstations and you will begin to learn how to use both OpenGL and GLUT to build graphics applications.
Write a program using OpenGL and GLUT to draw a simple picture of a house using an instructor-supplied program as a template.
Download the file box.cc by holding the shift key while left-clicking on the link for the file. Choose "Save link as" (or something similar if you're not using FireFox as your browser) to save the program.
I will want you to work on your projects in specific directories on the workstations; for this project that will be ~/cs373/p1. You may, of course, work on the program elsewhere as well, but when you've finished the project you must leave a copy of the source code and the executable in the ~/cs373/p1 directory.
Open a terminal shell and type
mkdir -p cs373/p1
to create the necessary directory. Now type
mv box.cc ~/cs373/p1
to move the program you've just downloaded to the proper directory then type
cd cs373/p1
to change to that directory. To compile the program, type
smake box.cc
press Enter and the program will be compiled. (Smake is a local program that carries out the commands listed in the $Smake: line at the top of the program source file. It is useful because it saves a lot of typing and lets you put the correct compilation command right in the source file. This is very nice when you want to compile something that you wrote a while back and don't remember the exact compilation command.)
Now run the program by typing
./box
and pressing Enter. A back window with three squares should pop up. When you are done, press q or the ESC key to quit the program.
Go back and look at the program source code again and make sure that you can figure out what each part of the program is doing. You can print the program with the command
lpr box.cc
and then connecting to https://printercontrol to authorize printing the file. The printer is located in MacDonald 110, the Introduction to Computer Science laboratory.
Now edit the file and try making small changes to the source, saving the source file, reissuing the smake command and rerunning the program to see the effects of the changes. Don't worry about changing your copy of the source, you can always get a fresh copy as described above.
Now for the main part of your first project. Copy the source code for the box program to the new file house.cc:
cp box.cc house.cc
Using the figure
(also available as a PDF file) as a plan, edit the file house.cc to create a computer program using GLUT and OpenGL that draws a picture of a house on the screen. Actually, all you need to do is change the body of the drawBox() function (you may want to change it's name as well) to draw the outline of the house, the door, windows, window boxes and the chimney. Your program should draw all the lines exactly as they appear on the plan (you don't need to draw the background grid). Pay special attention the coordinates of the points, especially those around the chimney. Feel free to experiment with different colors for the lines in your drawing.
If you're looking for ideas and examples, here are some student projects from previous years.
Please determine the answers to the following questions:
If you're anxious to try something else, change one of your GL_LINE_LOOP arguments to GL_POLYGON so that a solid polygon is generated. Can you make a nice picture of the house with solid polygons? How will you get the windows to look nice (i.e., have dark backgrounds, etc.)?
Your answers to the above questions, using the form above.
Hardcopy of your program(s).
Make sure that the source code and an executable version of your program is in your ~/cs373/p1 directory.