home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / EXAMPLES / POBJVWS.P < prev    next >
Text File  |  2000-02-11  |  3KB  |  177 lines

  1. program objvws;
  2.  
  3. #include "Vogle.h"
  4.  
  5.  
  6. const
  7.     CUBE = 1;
  8.     TOPLEFT = 2;
  9.     TOPRIGHT = 3;
  10.     BOTTOMLEFT = 4;
  11.     BOTTOMRIGHT = 5;
  12.  
  13. var
  14.     device: string_t;
  15.     i:    integer;
  16.  
  17.     (*
  18.      * side
  19.      *
  20.      *    define a face for the cube
  21.      *)
  22.     procedure side;
  23.     begin
  24.         PushMatrix;
  25.             Translate(0.0, 0.0, 1.0);
  26.             Rect(-1.0, -1.0, 1.0, 1.0);
  27.         PopMatrix;
  28.     end;
  29.  
  30.     (*
  31.      * makecube
  32.      *
  33.      *    set up a cube
  34.      *)
  35.     procedure makecube;
  36.     begin
  37.         MakeObj(CUBE);
  38.  
  39.             (*
  40.              * The border around the cube
  41.              *)
  42.             Rect(-5.0, -5.0, 10.0, 10.0);
  43.  
  44.             (*
  45.              * Make the cube from 4 squares
  46.              *)
  47.             PushMatrix;
  48.                 side;
  49.                 Rotate(90.0, 'x');
  50.                 side;
  51.                 Rotate(90.0, 'x');
  52.                 side;
  53.                 Rotate(90.0, 'x');
  54.                 side;
  55.             PopMatrix;
  56.  
  57.         CloseObj;
  58.     end;
  59.  
  60. begin
  61.  
  62.     write('Enter device name: ');
  63.     readln(device);
  64.     Vinit(device);
  65.  
  66.     PushViewPort;
  67.  
  68.     TextSize(0.5, 0.9);
  69.     Font('futura.m');
  70.  
  71.     Color(BLACK);
  72.     Clear;
  73.  
  74.     makecube;
  75.  
  76.     (*
  77.      * set up an object which draws in the top left of the screen.
  78.      *)
  79.     MakeObj(TOPLEFT);
  80.         ViewPort(-1.0, 0.0, 0.0, 1.0);
  81.         Ortho2(-5.0, 5.0, -5.0, 5.0);
  82.  
  83.         Color(RED);
  84.  
  85.         Rect(-5.0, -5.0, 5.0, 5.0);
  86.  
  87.         Perspective(40.0, 1.0, 0.1, 1000.0);
  88.         LookAt(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0);
  89.  
  90.         CallObj(CUBE);
  91.  
  92.         Color(GREEN);
  93.  
  94.         Move2(-4.5, -4.5);
  95.         DrawStr('perspective/lookat');
  96.     CloseObj;
  97.  
  98.     (*
  99.      * now set up one which draws in the top right of the screen
  100.      *)
  101.     MakeObj(TOPRIGHT);
  102.         ViewPort(0.0, 1.0, 0.0, 1.0);
  103.         Ortho2(-5.0, 5.0, -5.0, 5.0);
  104.  
  105.         Color(GREEN);
  106.  
  107.         Rect(-5.0, -5.0, 5.0, 5.0);
  108.  
  109.         Window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0);
  110.         LookAt(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0);
  111.  
  112.         CallObj(CUBE);
  113.  
  114.         Color(RED);
  115.  
  116.         Move2(-4.5, -4.5);
  117.         DrawStr('window/lookat');
  118.     CloseObj;
  119.  
  120.     (*
  121.      * try the bottom left
  122.      *)
  123.     MakeObj(BOTTOMLEFT);
  124.         ViewPort(-1.0, 0.0, -1.0, 0.0);
  125.         Ortho2(-5.0, 5.0, -5.0, 5.0);
  126.  
  127.         Color(MAGENTA);
  128.  
  129.         Rect(-5.0, -5.0, 5.0, 5.0);
  130.  
  131.         Perspective(40.0, 1.0, 0.1, 1000.0);
  132.         PolarView(15.0, 30.0, 30.0, 30.0);
  133.  
  134.         CallObj(CUBE);
  135.  
  136.         Color(YELLOW);
  137.  
  138.         Move2(-4.5, -4.5);
  139.         DrawStr('perspective/polarview');
  140.     CloseObj;
  141.  
  142.     (*
  143.      * and the bottom right
  144.      *)
  145.     MakeObj(BOTTOMRIGHT);
  146.         ViewPort(0.0, 1.0, -1.0, 0.0);
  147.         Ortho2(-5.0, 5.0, -5.0, 5.0);
  148.  
  149.         Color(CYAN);
  150.  
  151.         Rect(-5.0, -5.0, 5.0, 5.0);
  152.  
  153.         Window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0);
  154.         PolarView(8.0, -18.0, -3.0, 18.0);
  155.  
  156.         CallObj(CUBE);
  157.  
  158.         Color(BLUE);
  159.  
  160.         Move2(-4.5, -4.5);
  161.         DrawStr('window/polarview');
  162.     CloseObj;
  163.  
  164.     (*
  165.      * now draw them
  166.      *)
  167.     CallObj(TOPLEFT);
  168.     CallObj(TOPRIGHT);
  169.     CallObj(BOTTOMLEFT);
  170.     CallObj(BOTTOMRIGHT);
  171.  
  172.     i := GetKey;
  173.  
  174.     Vexit
  175. end.
  176.  
  177.