2.100 What is the general form of an OpenGL program? There are no hard and fast rules. The following pseudocode is generally recognized as good OpenGL form. program_entrypoint { // Determine which depth or pixel format should be used. // Create a window with the desired format. // Create a rendering context and make it current with the window. // Set up initial OpenGL state. // Set up callback routines for window resize and window refresh. } handle_resize { glViewport(...); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Set projection transform with glOrtho, glFrustum, // gluOrtho2D, gluPer spective, etc. } handle_refresh { glClear(...); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Set view transform with gluLookAt or equivalent // For each object (i) in the scene that needs to be rendered: // Push relevant stacks, e.g., glPushMatrix, glPushAttrib. // Set OpenGL state specific to object (i). // Set model transform for object (i) using glTranslatef, // glScalef, glRotatef, and/or equivalent. // Issue rendering commands for object (i). // Pop relevant stacks, (e.g., glPopMatrix, glPopAttrib.) // End for loop. // Swap buffers. }