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

0f   accomplish   all   and   answer   Answers   appear   Assignment   back   Be   be   becomes   before   between   bottom   buffering   by   calls   can   center   cetera   changes   color   comment   Commenting   Control   control   controls   coordinate   corner   created   default   direction   disappear   Display   display   displayed   does   double   down   Due   during   escape   et   exit   fast   following   for   frame   from   Func   function   functions   get   gl   glut   Goldgof   Greg   hand   he   height   How   how   If   in   In   Init   initialization   input   January   keep   keyboard   Keyboard   keys   left   line   main   make   makes   might   mode   Mode   moving   Notes   of   on   One   Open   Operation   or   original   Ortho   others   out   paramaters   parameter   parameters   passed   pointers   polygons   Port   positions   Press   program   Program   programmer   proportional   provided   psychedelic   questions   rather   Read   reference   relationship   reset   Reshape   reshape   reshaping   resize   resized   responds   right   rotations   S148   scaling   second   set   shapes   she   single   size   so   space   specifies   specify   squares   starter   starting   sure   take   than   that   The   the   their   therefore   These   these   this   tick   time   Timer   to   To   toggle   triangle   up   updates   use   via   View   Viewport   want   we   What   what   which   why   width   window   with   works   you  

    GregGoldgof/AssignmentOne

CS148 Assignment 1

Greg Goldgof

Due: January 18, 2007

Assignment One Answers

Read up on OpenGL and GLUT and answer the following questions. Be sure you can answer all these questions before moving on.

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

Control is passed to the programmer via function pointers. The glut functions

  • glutDisplayFunc( display ); glutReshapeFunc( reshape ); glutKeyboardFunc( keyboard ); glutTimerFunc(16.0f, tick, 0);

and others take function pointers as parameters during initialization. These functions are provided by the programmer, so that he/she can control what is displayed, how reshaping works, how the program responds to keyboard input, how it updates, et cetera.

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

The first parameter GLUT_RGBA specifies that we want out window to have color.

The second parameter GLUT_DOUBLE specifies that we want to use double buffering rather than single buffering, which is the default.

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() changes the coordinate reference frame. If you comment out the line from the starter code than (0, 0) becomes the center (by default) rather than the bottom left-hand corner.

glViewPort() controls scaling. Commenting out the line from the starter code makes it so that shapes created do not resize with the window. The paramaters (0, 0, w, h) keep the shapes proportional to the window size (width and height).

Program Operation

Notes on program: Pressspaceto get the squares to change direction. Press ‘f’ to toggle double-time (fast). Press ‘t’ to make the triangle appear or disappear. Press ‘c’ for a color change. Press ‘p’ for psychedelic mode. Pressescapeto exit.

To change the starting positions of the polygons and therefore the relationship between their rotations use the following keys. Press ‘r’ to reset back to original positions.

‘w’ = up

‘s’ = down

‘d’ = right

‘a’ = left


Recent