The older a man gets, the farther he had to walk to school as a boy! Concept 1.13: Animation ======================= Idea: ===== Click on the rendering screen with the left mouse button to start the animation. The code screen has certain function calls highlighted. Scroll down to the main() function. Double Buffering: ================= OpenGL provides double-buffering. One frame is displayed while the other is drawn. When the drawing of a frame is complete, the two buffers are swapped, so the one that was being viewed is now used for drawing, and vice versa. We initialize double buffering by a call to glutInitDisplayMode(GLUT_DOUBLE......); in the main function. We swap buffers to create an animation by calling glutSwapBuffers(); in our display() routine. To see how the animation would look like without double buffering, click on "Single Buffer" option and then execute the program as before. See a difference! Drawing a new frame: ==================== Scroll up to the spinDisplay() routine. Here we change the angle of rotation by updating spin. Once this is done we call glutPostRedisplay(); which calls the display() function and hence swaps buffers with the new spin value. This is why at each step the square appear slightly rotated (actually exactly rotated by spin degrees). Bring in the mice: ================== This is the easiest part. To enable swapping of buffers and starting the animation we use the void mouse() function. This function check to see which button the user has clicked and posts a call to glutIdleFunc() In our case the argument for glutIdleFunc() is either spinDisplay (if the user clicks with the left mouse button) to start spinning the square or NULL if the middle or right button were used (i.e do nothing and hence no animation). As simple as that!. Now you are ready to tackle some of the more involved examples I have which use translation and rotation.