The following 137 words could not be found in the dictionary of 615 words (including 615 LocalSpellingWords) and are highlighted below:

about   accomplish   alpha   an   and   answers   area   aspect   Assignment   back   be   Bezoari   blue   both   boundaries   buffering   By   call   callback   calls   can   cannot   certain   completely   contain   control   detected   different   Display   display   does   double   down   draw   draws   during   enable   enables   events   example   flattening   For   for   Func   function   functions   gl   glut   green   How   how   If   in   In   ing   Init   initialization   keyboard   Keyboard   keys   know   left   location   main   might   mode   Mode   modify   move   My   notes   of   opposite   Ortho   orthographic   out   Paolo   parameter   parameters   passed   performs   plane   press   program   programmer   projection   questions   ratio   rectangle   red   Reshape   reshape   resized   right   running   S148   same   scale   scene   set   sets   should   so   some   space   specifies   specify   stays   submit   that   The   the   them   thereby   these   this   to   too   triangle   up   use   user   using   Viewport   want   We   we   What   when   where   why   window   Write   write   you   your   Your  

    PaoloBezoariAssignment1

Paolo Bezoari CS148 Assignment 1

1. In a GLUT program, how is control passed back to the programmer? How is this set up during initialization?

In a GLUT program, control is passed back to the programmer using callback functions that we specify for certain events. For example, we use the glutKeyboardFunc() function to set the function to call when a keyboard press is detected and we use the glutReshapeFunc() function to set the function to call when the display is resized.

2. What does the parameter to glutInitDisplayMode() in main() specify?

GLUT_RGBA sets the window mode to RGBA (red-green-blue-alpha) and GLUT_DOUBLE enables double buffering of the window. By OR-ing these 2 parameters, we enable them both.

3. What do the calls to glOrtho() and glViewport() in the reshape() function accomplish? If the window is to be resized, why might we want to change this?

glOrtho() performs an orthographic projection of the space, thereby flattening it. The different parameters to glOrtho() specify the location of the projection plane in space. glViewport() specifies the area of the window where we should draw. If the window is resized, we might want to change the parameters to glOrtho() and glViewport() so that the aspect ratio of the scene stays the same for example. We can modify the parameters to these functions to do the opposite too: when the window is resized, the scene doesn't change scale.

4. Write up and submit your program. Your write up should contain both the answers to the questions and any notes we should know about running your program.

My program draws a rectangle using GL_LINES and a triangle using GL_TRIANGLES. By using the w/a/s/d keys, the user can move the triangle up/left/down/right in the scene. I have also set some boundaries so that you cannot move the triangle completely out of the rectangle.

Recent