Programming and Graphics

(Kiana) #1

212 Introduction to C++ Programming and Graphics


//--- Loop indefinitely:

while((but=slocator(&x, &y)) != 44)

{
pushmatrix();
rotate(120.0 * x, ’y’);
rotate(120.0 * y, ’x’);
color(BLACK);
clear();
color(20);
drawshape(1);
if (nplanes == 1)
{
drawshape(0);
}
popmatrix();
swapbuffers();

//--- Check the keyboard:

switch (but = checkkey())
{
case ’p’:
voutput("licosa.ps");
vnewdev("postscript");
pushmatrix();
rotate(100.0 * x, ’y’);
rotate(100.0 * y, ’x’);
color(BLACK);
clear();
drawshape(1);
if (nplanes == 1)
drawshape(0);
popmatrix();
vnewdev(device);
break;
case ’x’:
translate(tdir, 0.0, 0.0);
break;
case ’y’:
translate(0.0, tdir, 0.0);
break;
case ’z’:
translate(0.0, 0.0, tdir);
break;
case ’-’:
tdir = -tdir;
Free download pdf