|
EXERCISES FOR WEEK 1
|
| week1-1 | Using graph paper, pencil, and an X-Y coordinate system, draw a simple line design consisting of straight lines with at least 10 vertices (with integer coordinates). Draw a rectangular (not square) "frame" around the picture. This framed area will be the area you will display on the screen. Make note of the coordinates of the left, right, bottom, and top of the frame. |
| week1-2 | Using the demo program hello1.cpp as a guide, write a program that will display only the points of your picture. Choose a window size of 300 (width) by 400 (height). Notice that you will use the coordinates for left, right, bottom, top of the frame as the first four parameters in the glOrtho( ) function. The last two parameters of the function will always be (-1.0, 1.0) as long as we are using only two dimensions (near, far) .
Name the program week1_2.cpp
|
| week1-3 | Again, using the points you defined in exercise 1, change the GL_POINTS parameter to each of the following, in turn, and note the difference in the outcome.
|
| week1-4 | Now choose the appropriate parameters to correctly draw the picture you created in exercise 1. Be sure to choose the width and height of the rectangular window you create to match the ratio of the width and height of the frame you drew around it. This ensures that your design looks like the drawing your made. Save the program as week1_4.cpp
|
| week1-5 | Change the previous program (week1_4.cpp) so that the left, right, bottom, and top parameters to the glOrtho( ) function is different from the coordinates of the frame you drew:
|
| week1-6 | Change your design (using program week1_4.cpp)
so that you use floating point values for the points rather
than integer values. What additional changes must be made
to the program? Save the program as week1_6.cpp |
| week1-7 | Copy the file /classes/cs3014/files/week1/birchtree.jpg to your directory. Use xv (or gimp) to display the image on the screen.
Now open the .ppm file using a text editor.
Now write a simple C++ program (not necessary to use OpenGL) that
Display the new image using xv (or gimp). Try other changes, such as
|
| week1-8 | Write another fairly simple C++ program (not necessary to use OpenGL) that changes a .ppm file so that it has black stripes across it. That is, have your program determine the number of rows and columns in the image and, using that info, change some of the pixel values to all zeros, resulting in black pixels. You could start by making every other row black, but this will not be as dramatic as making several consecutive rows black. For example, the first 10 rows could remain unchanged, then the next 10 change to black, next 10 unchanged, etc.
|
| week1-9 | Copy the multiplewin.cpp file to your directory. Look it over carefully and make sure you understand what is going on in the program. Compile and run it.
|
| week1-10 | Change each of your programs so that the ESC key can be used to gracefully exit the program. Make sure you include this feature in all future programs you write.
|