7.3 A rotating polygon in animation 207
vexit();
return 0;
}
Figure 7.2.2(b) shows the generated graphics window. We see that the
viewportfunction combined with thepushmatrixandpopmatrixfunctions con-
siderably facilitates the drawing of composite shapes.
Vogledistribution codes
TheVogle distribution contains the following C programs: trivial.c
text.c, simple.c, slant.c, shapes.c, poly.c, views.c, circtxt.c, moretxt.c, getstr.c,
jtext.c, lstyles.c, curves.c, patches.c, balls.c, objvws.c, world.c, cube.c, licosa.c,
tetra.c, loc.c, lcube.c, beer.c, teapot.c.
These codes have been copied into the directory07/VOGLECexamples
of the software distribution accompanying this book. Translation into C++ is
both instructive and straightforward.
Problems
7.2.1. Generate aVoglewindow and print a word of your choice using a font
and color of your choice.
7.2.2. Generate aVoglewindow and draw the outline of a musical instrument
or your choice working in world coordinates.
7.2.3. Generate aVoglewindow and paint different colors at the four quad-
rants.
7.2.4. Translate into C++ aVogledistribution code of your choice.
7.3 Animation...............................
To perform animation, we use two memory spaces holding the graphics, one
called theback bufferand the second called theprimaryoractive buffer.The
computer displays the content of the primary buffer, and then the two buffers
are swapped in a process dubbeddouble buffering.
A rotating polygon
The following code contained in the filepoly2d.ccdisplays a rotating
polygon in animation: