EXERCISES FOR WEEK 2
week2-1

Use the demo program horiz_stripes3.cpp as a guide to write a display function that draws vertical stripes instead of horizontal stripes.

 

week2-2

Now put the horizontal stripes and vertical stripes together in the same program, using multiple windows. Have one window display horizontal stripes and a second window display vertical stripes.

week2-3

Add a third window to the program you wrote in exercise 2 so that it displays a "checkerboard".

 

week2-4

Suppose you have called glOrtho(0.0, 10.0, 0.0, 6.0, -1.0 1.0) and you are using the default viewport (entire screen window). The screen window width is 600 pixels (0 to 599) and its height is 400 pixels (0 to 399).

  • To what pixel value does the center of the frame (real window) (5.0, 3.0) map?
  • To what pixel value does the real point (4.0, 2.0) map?
week2-5

Suppose you have called glOrtho(-10.0, 10.0, -6.0, 6.0, -1.0, 1.0) and you are using the default viewport (entire screen window). The screen window width is 600 pixels (0 to 599) and its height is 400 pixels (0 to 399).

  • To what pixel value does the center of the frame (real window) (0.0, 0.0) map?
  • To what pixel value does the real point (4.0, -2.0) map?
week2-6

What is the aspect ratio of the real window frame defined in the previoius exercise?   If you are still using the default viewport,

  • suggest appropriate screen window dimensions to use that would preserve the aspect ratio of the scene.
  • what screen window height would you use if you need to set the screen window width to be 500 pixels?
  • what screen window width would you use if you need to set the screen window height to be 500 pixels?
week2-7

If you want to preserve the aspect ratio of the real window frame defined in exercise 7, but must use a square screen window (800 by 800 pixels), what values would you use for left, bottom, width, height in the call to

glViewport(left, bottom, width, height);

so that the viewport is centered both vertically and horizontally in the screen window and uses as much of the window as possible?

 

week2-8

Re-do exercise 9 using the real window frame defined by:

glOrtho(-6.0, 6.0, -10.0, 10.0, -1.0, 1.0)

 

week2-9

Do exercise 3.2.1 on page 958of the Hill textbook. *Don't skip this one.