Smoothing Animations

Freeze_Graph_Window and Update_Graph_Window are used to smooth the display of animations.  Without Freeze_Graph_Window, each redraw of a complex animation screen can take a noticeable amount of time, resulting in a very jerky animation.  

 

Freeze_Graph_Window helps the programmer avoid this problem by providing a special screen buffer to which graphics objects can be drawn.  After Freeze_Graph_Window is called (and before Unfreeze_Graph_Window is called), this buffer is used for all graphics calls.  That is, the objects being drawn by the graphics calls are not drawn to the screen, but instead to the screen buffer.  When the programmer has drawn the desired objects to the screen buffer, the Update_Graph_Window call is used to almost instantaneously move the screen buffer to the viewable graphics screen.  An animation normally repeats the following steps:

 

1)  Draw desired objects (to the screen buffer) using normal graphics calls (e.g., Draw_Circle, Draw_Line, etc.)

2)  Call Update_Graph_Window to make the drawn objects viewable (almost instantaneously)

 

When the animation is finished, or when the programmer wants graphics objects to appear immediately when called, the Unfreeze_Graph_Window routine is called.  This routine immediately updates the viewable screen with the contents of the screen buffer, and it forces subsequent graphics calls to immediately update the viewable screen rather than the screen buffer.

 

Example Program