CSCE 4230 Program #2 Due date: Thursday, February 19, 2009 Write an interactive OpenGL program that displays a rotating pendulum, centered in the window. The pendulum consists of a bob of radius r attached to an anchor point (the origin of the object coordinate system) by a rigid wire of length l, where r and l are global variables. Use r = 1.0 and l = 10.0. Modify double.c (OpenGL Programming Guide, pp. 24-25) as follows. 1) Replace display by a function that renders the pendulum with the bob rotated through angle spin from the vertical rest position. Draw a dot for the anchor point, a line segment for the wire, and a disk of radius r for the bob. Refer to OpenGL functions gluDisk, gluNewQuadric, and gluQuadricDrawStyle for drawing the disk. 2) In reshape, preserve the square aspect ratio, and define the view volume to be [-a,a] X [-a,a] for a = 1.25*l. 3) Add a keypress-handling function and a menu attached to the right mouse button with a keypress associated with each menu option for the following key/option pairs: a) '+': start the pendulum spinning counterclockwise by setting the spin increment to a positive value and registering spinDisplay as the idle callback; b) '-': start the pendulum spinning clockwise by setting the increment for spin to a negative value and registering spinDisplay as the idle callback; c) (ASCII 32): stop the spin by registering NULL as the idle callback; d) (ASCII 27): terminate the program (exit). The main program should call a function that creates the menu (by calling glutCreateMenu, glutAddMenuEntry, and glutAttachMenu) and registers a callback for the keypresses with glutKeyboardFunc (in addition to the mouse callback). The keyboard callback function should simply call the menu callback function. Function mouse in double.c need not be altered. Name the source code file prog2.c or prog2.cpp, and email it to the grader, Ismail Mohammed: im0058@unt.edu. Also, hand in a source code listing (with your name on it), at the beginning of class on the due date.