home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / avogl.tar.gz / avogl.tar / vogl / examples / fpoly.F < prev    next >
Text File  |  1992-09-22  |  3KB  |  210 lines

  1. c
  2. c drawpoly
  3. c
  4. c    draw some polygons
  5. c
  6.     subroutine drawpo
  7.  
  8.     
  9. #ifdef SGI
  10. #include "fgl.h"
  11. #else
  12. #include "fvogl.h"
  13. #endif
  14.     integer *2 val
  15. c
  16. c    An array of points for a polygon
  17. c
  18.     real parray(3,4)
  19.     real vec(3)
  20.  
  21.     data parray/ -8.0, -8.0, 0.0,
  22.      +          -5.0, -8.0, 0.0,
  23.      +          -5.0, -5.0, 0.0,
  24.      +          -8.0, -5.0, 0.0 /
  25.  
  26.     call color(YELLOW)
  27.  
  28. c
  29. c Draw a polygon using poly, parray is our array of
  30. c points and 4 is the number of points in it.
  31. c
  32.     call poly(4, parray)
  33.  
  34.     call color(GREEN)
  35.  
  36. c
  37. c Draw a 5 sided figure by using bgnpolygon, v3f and endpolygon
  38. c
  39.     call polymo(PYM_LI)
  40.     call bgnpol
  41.         vec(1) = 0.0 
  42.         vec(2) = 0.0 
  43.         vec(3) = 0.0
  44.         call v3f(vec)
  45.  
  46.         vec(1) = 3.0 
  47.         vec(2) = 0.0 
  48.         vec(3) = 0.0
  49.         call v3f(vec)
  50.         
  51.         vec(1) = 3.0 
  52.         vec(2) = 4.0 
  53.         vec(3) = 0.0
  54.         call v3f(vec)
  55.         
  56.         vec(1) = -1.0 
  57.         vec(2) = 5.0 
  58.         vec(3) = 0.0
  59.         call v3f(vec)
  60.         
  61.         vec(1) = -2.0 
  62.         vec(2) = 2.0 
  63.         vec(3) = 0.0
  64.         call v3f(vec)
  65.     call endpol
  66.  
  67.     call color(MAGENT)
  68.  
  69. c
  70. c draw a sector representing a 1/4 circle
  71. c
  72.     call arc(1.5, -7.0, 3.0, 0, 900)
  73.         
  74.     call move2(1.5, -7.0)
  75.     call draw2(1.5, -4.0)
  76.  
  77.     call move2(1.5, -7.0)
  78.     call draw2(4.5, -7.0)
  79.  
  80.  
  81.  
  82.     idum = qread(val)
  83.  
  84.     end
  85.  
  86. c
  87. c drawpolyf
  88. c
  89. c    draw some polygons
  90. c
  91.     subroutine drawpf
  92.  
  93. #ifdef SGI
  94. #include "fgl.h"
  95. #else
  96. #include "fvogl.h"
  97. #endif
  98.     
  99.     integer *2 val
  100. c
  101. c    An array of points for a polygon
  102. c
  103.     real parray(3,4)
  104.  
  105.     data parray/ -8.0, -8.0, 0.0,
  106.      +          -5.0, -8.0, 0.0,
  107.      +          -5.0, -5.0, 0.0,
  108.      +          -8.0, -5.0, 0.0 /
  109.  
  110.     call color(YELLOW)
  111.  
  112.     call polymo(PYM_FI)
  113. c
  114. c Draw a polygon using poly, parray is our array of
  115. c points and 4 is the number of points in it.
  116. c
  117.     call polf(4, parray)
  118.  
  119.     call color(GREEN)
  120.  
  121.         call pmv(0.0, 0.0, 0.0)
  122.                 call pdr(3.0, 0.0, 0.0)
  123.                 call pdr(3.0, 4.0, 0.0)
  124.                 call pdr(-1.0, 5.0, 0.0)
  125.                 call pdr(-2.0, 2.0, 0.0)
  126.         call pclos()
  127.  
  128.         call color(MAGENT)
  129.  
  130. c
  131. c draw a filled sector representing a 1/4 circle
  132. c
  133.         call arcf(1.5, -7.0, 3.0, 0, 900)
  134.  
  135.     idum = qread(val)
  136.  
  137.     end
  138. c
  139. c Using polygons, hatching, and filling.
  140. c
  141.     program fpoly
  142. #include "fvogl.h"
  143. #include "fvodevice.h"
  144.  
  145.     call winope('fpoly', 5)
  146.  
  147. c
  148. c    We are interested in keyboard events
  149. c
  150.     call unqdev(INPUTC)
  151.     call qdevic(KEYBD)
  152.  
  153. c
  154. c load a hershey font
  155. c
  156.     call hfont('futura.l', 8)
  157. c
  158. c clear to black
  159. c
  160.     call color(BLACK)
  161.     call clear
  162.  
  163. c
  164. c world coordinates are now in the range -10 to 10
  165. c in x, y, and z. Note that positive z is towards us.
  166. c
  167.     call ortho(-10.0, 10.0, -10.0, 10.0, 10.0, -10.0)
  168.  
  169.     call color(YELLOW)
  170.  
  171. c
  172. c write out the string "Polygon from poly()" in the
  173. c starting at (-8.0, -4.0) and scaled to be 4.0 units long,
  174. c 0.5 units high.
  175. c
  176.     call hboxte(-8.0, -4.0, 4.0, 0.5,
  177.      +   'Polygon from poly()/ polf()', 27)
  178.  
  179.     call color(GREEN)
  180.  
  181. c
  182. c write out a scaled string starting at (0.0, 6.0)
  183. c
  184.     call hboxte(0.0, 6.0, 4.5, 0.5,
  185.      +   'Polygon from bgnpol()/ endpol()', 31)
  186.     call hboxte(0.0, 5.0, 4.5, 0.5,
  187.      +   '             pmv()/ pdr()/ pclos()', 34)
  188.  
  189.     call color(MAGENT)
  190.  
  191. c
  192. c draw some polygons
  193. c
  194.     call drawpo
  195.  
  196. c
  197. c  Rotate 20 degrees around x and 30 around y
  198. c
  199.     call rotate(200, 'x')
  200.     call rotate(300, 'y')
  201.  
  202. c
  203. c draw some polygons with filling
  204. c
  205.     call drawpf
  206.  
  207.     call gexit
  208.  
  209.     end
  210.