CS 420 Computer Graphics


Lab 3
Dr. Tong Yu, Fall 2009

Windowing and Drawing Objects

  • Login and open two windows, one for editing and one for compiling and executing programs. Make a new directory called draw2. Copy the draw programs discussed in lab1 to your draw2 directory. Do the following:
    1. The current display window size is 500 x 500. Change it to 200 x 300. ( Hint : modify parameters to function glutInitWindowSize(); )
      After you have successfully made the modifications, try two more sizes.
    2. The current window is displayed at screen position ( 100, 150 ). Change it to position ( 300, 350 ). ( Hint, modify parameters to glutInitWindowPosition(); ).
      After you have successfully made the modifications, try two more different positions.
    3. Change the world window settings and see what happens. ( Hint: modify parameters to gluOrtho2D(); )
    4. Restore your program to the original draw. ( You may copy the program over again from the instructor's directory. ) In the beginning of display() function, add the statement, glViewport( 0, 0, 50, 50);. Recompile and run your program. What happens? Try to change the statement to, say, glViewport ( 150, 200, 250, 100 ) and see what would happen.

  • Make another directory called bresenham.
    • Try the Bresenham's Line and Circle algorithms discussed in class.
    • Use the line algorithm to draw a line with end points (0, 0 ) and ( 200, 100 ).
    • Use the circle algorithm to draw a circle with radious 20.