home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / voglew.zip / TEAPOT.C < prev    next >
C/C++ Source or Header  |  1993-05-28  |  15KB  |  512 lines

  1.  
  2. #include <stdio.h>
  3. #include "vogle.h"
  4.  
  5. /*
  6.  *    Draws Newell's Teapot as a heap of Bezier surface patches.
  7.  */
  8.  
  9.  
  10. #define    TEAPOT        1
  11. #define    ESC        27
  12.  
  13. /*
  14.  *    Data for the teapot.
  15.  */
  16. #define    NUM_PNTS    306
  17. #define    NUM_PATCH    32 
  18.  
  19. float    xyz[NUM_PNTS][3] = {
  20.     { 1.400,   0.000,   2.400},
  21.     { 1.400,  -0.784,   2.400},
  22.     { 0.784,  -1.400,   2.400},
  23.     { 0.000,  -1.400,   2.400},
  24.     { 1.337,   0.000,   2.531},
  25.     { 1.337,  -0.749,   2.531},
  26.     { 0.749,  -1.337,   2.531},
  27.     { 0.000,  -1.337,   2.531},
  28.     { 1.438,   0.000,   2.531},
  29.     { 1.438,  -0.805,   2.531},
  30.     { 0.805,  -1.438,   2.531},
  31.     { 0.000,  -1.438,   2.531},
  32.     { 1.500,   0.000,   2.400},
  33.     { 1.500,  -0.840,   2.400},
  34.     { 0.840,  -1.500,   2.400},
  35.     { 0.000,  -1.500,   2.400},
  36.     {-0.784,  -1.400,   2.400},
  37.     {-1.400,  -0.784,   2.400},
  38.     {-1.400,   0.000,   2.400},
  39.     {-0.749,  -1.337,   2.531},
  40.     {-1.337,  -0.749,   2.531},
  41.     {-1.337,   0.000,   2.531},
  42.     {-0.805,  -1.438,   2.531},
  43.     {-1.438,  -0.805,   2.531},
  44.     {-1.438,   0.000,   2.531},
  45.     {-0.840,  -1.500,   2.400},
  46.     {-1.500,  -0.840,   2.400},
  47.     {-1.500,   0.000,   2.400},
  48.     {-1.400,   0.784,   2.400},
  49.     {-0.784,   1.400,   2.400},
  50.     { 0.000,   1.400,   2.400},
  51.     {-1.337,   0.749,   2.531},
  52.     {-0.749,   1.337,   2.531},
  53.     { 0.000,   1.337,   2.531},
  54.     {-1.438,   0.805,   2.531},
  55.     {-0.805,   1.438,   2.531},
  56.     { 0.000,   1.438,   2.531},
  57.     {-1.500,   0.840,   2.400},
  58.     {-0.840,   1.500,   2.400},
  59.     { 0.000,   1.500,   2.400},
  60.     { 0.784,   1.400,   2.400},
  61.     { 1.400,   0.784,   2.400},
  62.     { 0.749,   1.337,   2.531},
  63.     { 1.337,   0.749,   2.531},
  64.     { 0.805,   1.438,   2.531},
  65.     { 1.438,   0.805,   2.531},
  66.     { 0.840,   1.500,   2.400},
  67.     { 1.500,   0.840,   2.400},
  68.     { 1.750,   0.000,   1.875},
  69.     { 1.750,  -0.980,   1.875},
  70.     { 0.980,  -1.750,   1.875},
  71.     { 0.000,  -1.750,   1.875},
  72.     { 2.000,   0.000,   1.350},
  73.     { 2.000,  -1.120,   1.350},
  74.     { 1.120,  -2.000,   1.350},
  75.     { 0.000,  -2.000,   1.350},
  76.     { 2.000,   0.000,   0.900},
  77.     { 2.000,  -1.120,   0.900},
  78.     { 1.120,  -2.000,   0.900},
  79.     { 0.000,  -2.000,   0.900},
  80.     {-0.980,  -1.750,   1.875},
  81.     {-1.750,  -0.980,   1.875},
  82.     {-1.750,   0.000,   1.875},
  83.     {-1.120,  -2.000,   1.350},
  84.     {-2.000,  -1.120,   1.350},
  85.     {-2.000,   0.000,   1.350},
  86.     {-1.120,  -2.000,   0.900},
  87.     {-2.000,  -1.120,   0.900},
  88.     {-2.000,   0.000,   0.900},
  89.     {-1.750,   0.980,   1.875},
  90.     {-0.980,   1.750,   1.875},
  91.     { 0.000,   1.750,   1.875},
  92.     {-2.000,   1.120,   1.350},
  93.     {-1.120,   2.000,   1.350},
  94.     { 0.000,   2.000,   1.350},
  95.     {-2.000,   1.120,   0.900},
  96.     {-1.120,   2.000,   0.900},
  97.     { 0.000,   2.000,   0.900},
  98.     { 0.980,   1.750,   1.875},
  99.     { 1.750,   0.980,   1.875},
  100.     { 1.120,   2.000,   1.350},
  101.     { 2.000,   1.120,   1.350},
  102.     { 1.120,   2.000,   0.900},
  103.     { 2.000,   1.120,   0.900},
  104.     { 2.000,   0.000,   0.450},
  105.     { 2.000,  -1.120,   0.450},
  106.     { 1.120,  -2.000,   0.450},
  107.     { 0.000,  -2.000,   0.450},
  108.     { 1.500,   0.000,   0.225},
  109.     { 1.500,  -0.840,   0.225},
  110.     { 0.840,  -1.500,   0.225},
  111.     { 0.000,  -1.500,   0.225},
  112.     { 1.500,   0.000,   0.150},
  113.     { 1.500,  -0.840,   0.150},
  114.     { 0.840,  -1.500,   0.150},
  115.     { 0.000,  -1.500,   0.150},
  116.     {-1.120,  -2.000,   0.450},
  117.     {-2.000,  -1.120,   0.450},
  118.     {-2.000,   0.000,   0.450},
  119.     {-0.840,  -1.500,   0.225},
  120.     {-1.500,  -0.840,   0.225},
  121.     {-1.500,   0.000,   0.225},
  122.     {-0.840,  -1.500,   0.150},
  123.     {-1.500,  -0.840,   0.150},
  124.     {-1.500,   0.000,   0.150},
  125.     {-2.000,   1.120,   0.450},
  126.     {-1.120,   2.000,   0.450},
  127.     { 0.000,   2.000,   0.450},
  128.     {-1.500,   0.840,   0.225},
  129.     {-0.840,   1.500,   0.225},
  130.     { 0.000,   1.500,   0.225},
  131.     {-1.500,   0.840,   0.150},
  132.     {-0.840,   1.500,   0.150},
  133.     { 0.000,   1.500,   0.150},
  134.     { 1.120,   2.000,   0.450},
  135.     { 2.000,   1.120,   0.450},
  136.     { 0.840,   1.500,   0.225},
  137.     { 1.500,   0.840,   0.225},
  138.     { 0.840,   1.500,   0.150},
  139.     { 1.500,   0.840,   0.150},
  140.     {-1.600,   0.000,   2.025},
  141.     {-1.600,  -0.300,   2.025},
  142.     {-1.500,  -0.300,   2.250},
  143.     {-1.500,   0.000,   2.250},
  144.     {-2.300,   0.000,   2.025},
  145.     {-2.300,  -0.300,   2.025},
  146.     {-2.500,  -0.300,   2.250},
  147.     {-2.500,   0.000,   2.250},
  148.     {-2.700,   0.000,   2.025},
  149.     {-2.700,  -0.300,   2.025},
  150.     {-3.000,  -0.300,   2.250},
  151.     {-3.000,   0.000,   2.250},
  152.     {-2.700,   0.000,   1.800},
  153.     {-2.700,  -0.300,   1.800},
  154.     {-3.000,  -0.300,   1.800},
  155.     {-3.000,   0.000,   1.800},
  156.     {-1.500,   0.300,   2.250},
  157.     {-1.600,   0.300,   2.025},
  158.     {-2.500,   0.300,   2.250},
  159.     {-2.300,   0.300,   2.025},
  160.     {-3.000,   0.300,   2.250},
  161.     {-2.700,   0.300,   2.025},
  162.     {-3.000,   0.300,   1.800},
  163.     {-2.700,   0.300,   1.800},
  164.     {-2.700,   0.000,   1.575},
  165.     {-2.700,  -0.300,   1.575},
  166.     {-3.000,  -0.300,   1.350},
  167.     {-3.000,   0.000,   1.350},
  168.     {-2.500,   0.000,   1.125},
  169.     {-2.500,  -0.300,   1.125},
  170.     {-2.650,  -0.300,   0.938},
  171.     {-2.650,   0.000,   0.938},
  172.     {-2.000,  -0.300,   0.900},
  173.     {-1.900,  -0.300,   0.600},
  174.     {-1.900,   0.000,   0.600},
  175.     {-3.000,   0.300,   1.350},
  176.     {-2.700,   0.300,   1.575},
  177.     {-2.650,   0.300,   0.938},
  178.     {-2.500,   0.300,   1.125},
  179.     {-1.900,   0.300,   0.600},
  180.     {-2.000,   0.300,   0.900},
  181.     { 1.700,   0.000,   1.425},
  182.     { 1.700,  -0.660,   1.425},
  183.     { 1.700,  -0.660,   0.600},
  184.     { 1.700,   0.000,   0.600},
  185.     { 2.600,   0.000,   1.425},
  186.     { 2.600,  -0.660,   1.425},
  187.     { 3.100,  -0.660,   0.825},
  188.     { 3.100,   0.000,   0.825},
  189.     { 2.300,   0.000,   2.100},
  190.     { 2.300,  -0.250,   2.100},
  191.     { 2.400,  -0.250,   2.025},
  192.     { 2.400,   0.000,   2.025},
  193.     { 2.700,   0.000,   2.400},
  194.     { 2.700,  -0.250,   2.400},
  195.     { 3.300,  -0.250,   2.400},
  196.     { 3.300,   0.000,   2.400},
  197.     { 1.700,   0.660,   0.600},
  198.     { 1.700,   0.660,   1.425},
  199.     { 3.100,   0.660,   0.825},
  200.     { 2.600,   0.660,   1.425},
  201.     { 2.400,   0.250,   2.025},
  202.     { 2.300,   0.250,   2.100},
  203.     { 3.300,   0.250,   2.400},
  204.     { 2.700,   0.250,   2.400},
  205.     { 2.800,   0.000,   2.475},
  206.     { 2.800,  -0.250,   2.475},
  207.     { 3.525,  -0.250,   2.494},
  208.     { 3.525,   0.000,   2.494},
  209.     { 2.900,   0.000,   2.475},
  210.     { 2.900,  -0.150,   2.475},
  211.     { 3.450,  -0.150,   2.513},
  212.     { 3.450,   0.000,   2.513},
  213.     { 2.800,   0.000,   2.400},
  214.     { 2.800,  -0.150,   2.400},
  215.     { 3.200,  -0.150,   2.400},
  216.     { 3.200,   0.000,   2.400},
  217.     { 3.525,   0.250,   2.494},
  218.     { 2.800,   0.250,   2.475},
  219.     { 3.450,   0.150,   2.513},
  220.     { 2.900,   0.150,   2.475},
  221.     { 3.200,   0.150,   2.400},
  222.     { 2.800,   0.150,   2.400},
  223.     { 0.000,   0.000,   3.150},
  224.     { 0.000,  -0.002,   3.150},
  225.     { 0.002,   0.000,   3.150},
  226.     { 0.800,   0.000,   3.150},
  227.     { 0.800,  -0.450,   3.150},
  228.     { 0.450,  -0.800,   3.150},
  229.     { 0.000,  -0.800,   3.150},
  230.     { 0.000,   0.000,   2.850},
  231.     { 0.200,   0.000,   2.700},
  232.     { 0.200,  -0.112,   2.700},
  233.     { 0.112,  -0.200,   2.700},
  234.     { 0.000,  -0.200,   2.700},
  235.     {-0.002,   0.000,   3.150},
  236.     {-0.450,  -0.800,   3.150},
  237.     {-0.800,  -0.450,   3.150},
  238.     {-0.800,   0.000,   3.150},
  239.     {-0.112,  -0.200,   2.700},
  240.     {-0.200,  -0.112,   2.700},
  241.     {-0.200,   0.000,   2.700},
  242.     { 0.000,   0.002,   3.150},
  243.     {-0.800,   0.450,   3.150},
  244.     {-0.450,   0.800,   3.150},
  245.     { 0.000,   0.800,   3.150},
  246.     {-0.200,   0.112,   2.700},
  247.     {-0.112,   0.200,   2.700},
  248.     { 0.000,   0.200,   2.700},
  249.     { 0.450,   0.800,   3.150},
  250.     { 0.800,   0.450,   3.150},
  251.     { 0.112,   0.200,   2.700},
  252.     { 0.200,   0.112,   2.700},
  253.     { 0.400,   0.000,   2.550},
  254.     { 0.400,  -0.224,   2.550},
  255.     { 0.224,  -0.400,   2.550},
  256.     { 0.000,  -0.400,   2.550},
  257.     { 1.300,   0.000,   2.550},
  258.     { 1.300,  -0.728,   2.550},
  259.     { 0.728,  -1.300,   2.550},
  260.     { 0.000,  -1.300,   2.550},
  261.     { 1.300,   0.000,   2.400},
  262.     { 1.300,  -0.728,   2.400},
  263.     { 0.728,  -1.300,   2.400},
  264.     { 0.000,  -1.300,   2.400},
  265.     {-0.224,  -0.400,   2.550},
  266.     {-0.400,  -0.224,   2.550},
  267.     {-0.400,   0.000,   2.550},
  268.     {-0.728,  -1.300,   2.550},
  269.     {-1.300,  -0.728,   2.550},
  270.     {-1.300,   0.000,   2.550},
  271.     {-0.728,  -1.300,   2.400},
  272.     {-1.300,  -0.728,   2.400},
  273.     {-1.300,   0.000,   2.400},
  274.     {-0.400,   0.224,   2.550},
  275.     {-0.224,   0.400,   2.550},
  276.     { 0.000,   0.400,   2.550},
  277.     {-1.300,   0.728,   2.550},
  278.     {-0.728,   1.300,   2.550},
  279.     { 0.000,   1.300,   2.550},
  280.     {-1.300,   0.728,   2.400},
  281.     {-0.728,   1.300,   2.400},
  282.     { 0.000,   1.300,   2.400},
  283.     { 0.224,   0.400,   2.550},
  284.     { 0.400,   0.224,   2.550},
  285.     { 0.728,   1.300,   2.550},
  286.     { 1.300,   0.728,   2.550},
  287.     { 0.728,   1.300,   2.400},
  288.     { 1.300,   0.728,   2.400},
  289.     { 0.000,   0.000,   0.000},
  290.     { 1.500,   0.000,   0.150},
  291.     { 1.500,   0.840,   0.150},
  292.     { 0.840,   1.500,   0.150},
  293.     { 0.000,   1.500,   0.150},
  294.     { 1.500,   0.000,   0.075},
  295.     { 1.500,   0.840,   0.075},
  296.     { 0.840,   1.500,   0.075},
  297.     { 0.000,   1.500,   0.075},
  298.     { 1.425,   0.000,   0.000},
  299.     { 1.425,   0.798,   0.000},
  300.     { 0.798,   1.425,   0.000},
  301.     { 0.000,   1.425,   0.000},
  302.     {-0.840,   1.500,   0.150},
  303.     {-1.500,   0.840,   0.150},
  304.     {-1.500,   0.000,   0.150},
  305.     {-0.840,   1.500,   0.075},
  306.     {-1.500,   0.840,   0.075},
  307.     {-1.500,   0.000,   0.075},
  308.     {-0.798,   1.425,   0.000},
  309.     {-1.425,   0.798,   0.000},
  310.     {-1.425,   0.000,   0.000},
  311.     {-1.500,  -0.840,   0.150},
  312.     {-0.840,  -1.500,   0.150},
  313.     { 0.000,  -1.500,   0.150},
  314.     {-1.500,  -0.840,   0.075},
  315.     {-0.840,  -1.500,   0.075},
  316.     { 0.000,  -1.500,   0.075},
  317.     {-1.425,  -0.798,   0.000},
  318.     {-0.798,  -1.425,   0.000},
  319.     { 0.000,  -1.425,   0.000},
  320.     { 0.840,  -1.500,   0.150},
  321.     { 1.500,  -0.840,   0.150},
  322.     { 0.840,  -1.500,   0.075},
  323.     { 1.500,  -0.840,   0.075},
  324.     { 0.798,  -1.425,   0.000},
  325.     { 1.425,  -0.798,   0.000}
  326. };
  327.  
  328. int    patches[NUM_PATCH][16] = {
  329.     {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,  16},
  330.     {  4,  17,  18,  19,   8,  20,  21,  22,  12,  23,  24,  25,  16,  26,  27,  28},
  331.     { 19,  29,  30,  31,  22,  32,  33,  34,  25,  35,  36,  37,  28,  38,  39,  40},
  332.     { 31,  41,  42,   1,  34,  43,  44,   5,  37,  45,  46,   9,  40,  47,  48,  13},
  333.     { 13,  14,  15,  16,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60},
  334.     { 16,  26,  27,  28,  52,  61,  62,  63,  56,  64,  65,  66,  60,  67,  68,  69},
  335.     { 28,  38,  39,  40,  63,  70,  71,  72,  66,  73,  74,  75,  69,  76,  77,  78},
  336.     { 40,  47,  48,  13,  72,  79,  80,  49,  75,  81,  82,  53,  78,  83,  84,  57},
  337.     { 57,  58,  59,  60,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,  96},
  338.     { 60,  67,  68,  69,  88,  97,  98,  99,  92, 100, 101, 102,  96, 103, 104, 105},
  339.     { 69,  76,  77,  78,  99, 106, 107, 108, 102, 109, 110, 111, 105, 112, 113, 114},
  340.     { 78,  83,  84,  57, 108, 115, 116,  85, 111, 117, 118,  89, 114, 119, 120,  93},
  341.     {121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136},
  342.     {124, 137, 138, 121, 128, 139, 140, 125, 132, 141, 142, 129, 136, 143, 144, 133},
  343.     {133, 134, 135, 136, 145, 146, 147, 148, 149, 150, 151, 152,  69, 153, 154, 155},
  344.     {136, 143, 144, 133, 148, 156, 157, 145, 152, 158, 159, 149, 155, 160, 161,  69},
  345.     {162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177},
  346.     {165, 178, 179, 162, 169, 180, 181, 166, 173, 182, 183, 170, 177, 184, 185, 174},
  347.     {174, 175, 176, 177, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197},
  348.     {177, 184, 185, 174, 189, 198, 199, 186, 193, 200, 201, 190, 197, 202, 203, 194},
  349.     {204, 204, 204, 204, 207, 208, 209, 210, 211, 211, 211, 211, 212, 213, 214, 215},
  350.     {204, 204, 204, 204, 210, 217, 218, 219, 211, 211, 211, 211, 215, 220, 221, 222},
  351.     {204, 204, 204, 204, 219, 224, 225, 226, 211, 211, 211, 211, 222, 227, 228, 229},
  352.     {204, 204, 204, 204, 226, 230, 231, 207, 211, 211, 211, 211, 229, 232, 233, 212},
  353.     {212, 213, 214, 215, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245},
  354.     {215, 220, 221, 222, 237, 246, 247, 248, 241, 249, 250, 251, 245, 252, 253, 254},
  355.     {222, 227, 228, 229, 248, 255, 256, 257, 251, 258, 259, 260, 254, 261, 262, 263},
  356.     {229, 232, 233, 212, 257, 264, 265, 234, 260, 266, 267, 238, 263, 268, 269, 242},
  357.     {270, 270, 270, 270, 279, 280, 281, 282, 275, 276, 277, 278, 271, 272, 273, 274},
  358.     {270, 270, 270, 270, 282, 289, 290, 291, 278, 286, 287, 288, 274, 283, 284, 285},
  359.     {270, 270, 270, 270, 291, 298, 299, 300, 288, 295, 296, 297, 285, 292, 293, 294},
  360.     {270, 270, 270, 270, 300, 305, 306, 279, 297, 303, 304, 275, 294, 301, 302, 271}
  361. };
  362.  
  363.  
  364. /*
  365.  * patch basis type
  366.  */
  367.  
  368. Matrix    bezier = {
  369.     {-1.0,    3.0,    -3.0,    1.0},
  370.     {3.0,    -6.0,    3.0,    0.0},
  371.     {-3.0,    3.0,    0.0,    0.0},
  372.     {1.0,    0.0,    0.0,    0.0} 
  373. };
  374.  
  375. Matrix    x, y, z;
  376.  
  377. extern    int    atoi();
  378.  
  379. main(argc, argv)
  380.     int    argc;
  381.     char    **argv;
  382. {
  383.     char    dev[20];
  384.     int    i, j, k, params[4];
  385.  
  386. /*
  387.     fprintf(stderr, "Using %s:\n\n", argv[0]);
  388.  
  389.     fprintf(stderr, "Use the 'q' key to quit\n");
  390.     fprintf(stderr, "Use the 'x' key to rotate about x\n");
  391.     fprintf(stderr, "Use the 'y' key to rotate about y\n");
  392.     fprintf(stderr, "Use the 'z' key to rotate about z\n");
  393.     fprintf(stderr, "Use the 'e' key to enlarge\n");
  394.     fprintf(stderr, "Use the 'r' key to reduce\n");
  395.     fprintf(stderr, "Use the 'p' key to produce a postscript file\n");
  396.     fprintf(stderr, "   of the current view (teapot.ps)\n");
  397.     fprintf(stderr, "Use the 'h' key to produce a hpgl file\n");
  398.     fprintf(stderr, "   of the current view (teapot.hp)\n\n");
  399.  
  400.     fprintf(stderr,"Enter output device: ");
  401.     gets(dev);
  402. */
  403.  
  404.     params[0] = params[1] = 4;
  405.     params[2] = params[3] = 6;
  406.  
  407.     if (argc > 2) 
  408.         for (i = 2; i < argc; i++)
  409.             params[i - 2] = atoi(argv[i]);
  410.  
  411.     vinit("mswin");          /* set up device */
  412.  
  413.     color(BLACK);
  414.     clear();
  415.  
  416.     window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0);
  417.     lookat(0.0, 0.0, 8.0, 0.0, 0.0, 0.0, 0.0);
  418.  
  419.     patchcurves(params[0], params[1]);
  420.     patchprecision(params[2], params[3]);
  421.     patchbasis(bezier, bezier);
  422.  
  423.     /*
  424.      * Make an object with the teapot in it.
  425.      */
  426.  
  427.     makeobj(TEAPOT);
  428.         color(CYAN);
  429.         for (i = 0; i < NUM_PATCH; i++) {
  430.             /*
  431.              * Set up geometry arrays...
  432.              */
  433.             for (j = 0; j < 4; j++) {
  434.                 x[0][j] = xyz[patches[i][j] - 1][0];
  435.                 x[1][j] = xyz[patches[i][j + 4] - 1][0];
  436.                 x[2][j] = xyz[patches[i][j + 8] - 1][0];
  437.                 x[3][j] = xyz[patches[i][j + 12] - 1][0];
  438.  
  439.                 y[0][j] = xyz[patches[i][j] - 1][1];
  440.                 y[1][j] = xyz[patches[i][j + 4] - 1][1];
  441.                 y[2][j] = xyz[patches[i][j + 8] - 1][1];
  442.                 y[3][j] = xyz[patches[i][j + 12] - 1][1];
  443.  
  444.                 z[0][j] = xyz[patches[i][j] - 1][2];
  445.                 z[1][j] = xyz[patches[i][j + 4] - 1][2];
  446.                 z[2][j] = xyz[patches[i][j + 8] - 1][2];
  447.                 z[3][j] = xyz[patches[i][j + 12] - 1][2];
  448.             }
  449.             /*
  450.              * Draw it...
  451.              */
  452.             patch(x, y, z);
  453.         }
  454.     closeobj();
  455.  
  456.     backbuffer();
  457.  
  458.     while (1) {
  459.  
  460.         color(BLACK);
  461.         clear();
  462.         callobj(TEAPOT);
  463.  
  464.  
  465.         swapbuffers();
  466.  
  467.         switch (getkey()) {
  468.         case 'q':    /* Stop the program */
  469.         case ESC:
  470.             vexit();
  471.             exit(0);
  472.  
  473.         case 'p':    /* Do a postscript plot of it */
  474.             voutput("teapot.ps");
  475.             vnewdev("postscript");
  476.             callobj(TEAPOT);
  477.             vnewdev(dev);
  478.             break;
  479.  
  480.         case 'h':    /* Do a hpgl plot of it */
  481.             voutput("teapot.hp");
  482.             vnewdev("hpgl");
  483.             callobj(TEAPOT);
  484.             vnewdev(dev);
  485.             break;
  486.  
  487.         case 'x':    /* Obvious isn't it */
  488.             rotate(10.0, 'x');
  489.             break;
  490.  
  491.         case 'y':
  492.             rotate(10.0, 'y');
  493.             break;
  494.  
  495.         case 'z':
  496.             rotate(10.0, 'z');
  497.             break;
  498.  
  499.         case 'e':    /* Enlarge */
  500.             scale(1.1, 1.1, 1.1);
  501.             break;
  502.  
  503.         case 'r':    /* Reduce */
  504.             scale(0.9, 0.9, 0.9);
  505.             break;
  506.  
  507.         default:
  508.             ;
  509.         }
  510.     }
  511. }
  512.