morph3d.pp 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. {
  2. $Id$
  3. *-
  4. * morph3d.c - Shows 3D morphing objects
  5. *
  6. * Converted to GLUT by brianp on 1/1/98
  7. * Converted to FreePascal by Peter Vreman on 9/3/2000
  8. *
  9. * This program was inspired on a WindowsNT(R)'s screen saver. It was written
  10. * from scratch and it was not based on any other source code.
  11. *
  12. * Porting it to xlock (the final objective of this code since the moment I
  13. * decided to create it) was possible by comparing the original Mesa's gear
  14. * demo with it's ported version, so thanks for Danny Sung for his indirect
  15. * help (look at gear.c in xlock source tree). NOTE: At the moment this code
  16. * was sent to Brian Paul for package inclusion, the XLock Version was not
  17. * available. In fact, I'll wait it to appear on the next Mesa release (If you
  18. * are reading this, it means THIS release) to send it for xlock package
  19. * inclusion). It will probably there be a GLUT version too.
  20. *
  21. * Thanks goes also to Brian Paul for making it possible and inexpensive
  22. * to use OpenGL at home. *
  23. * Since I'm not a native english speaker, my apologies for any gramatical
  24. * mistake.
  25. *
  26. * My e-mail addresses are
  27. *
  28. * [email protected]
  29. * and
  30. * [email protected]
  31. *
  32. * Marcelo F. Vianna (Feb-13-1997)
  33. */
  34. }
  35. program morph3d;
  36. {$Mode objfpc}
  37. {$MACRO ON}
  38. {$ifdef win32}
  39. {$define extdecl := stdcall;}
  40. {$endif}
  41. {$ifdef linux}
  42. {$define extdecl := cdecl;}
  43. {$endif}
  44. {
  45. This document is VERY incomplete, but tries to describe the mathematics used
  46. in the program. At this moment it just describes how the polyhedra are
  47. generated. On futhurer versions, this document will be probabbly improved.
  48. Since I'm not a native english speaker, my apologies for any gramatical
  49. mistake.
  50. Marcelo Fernandes Vianna
  51. - Undergraduate in Computer Engeneering at Catholic Pontifical University
  52. - of Rio de Janeiro (PUC-Rio) Brasil.
  53. - e-mail: [email protected] or [email protected]
  54. - Feb-13-1997
  55. POLYHEDRA GENERATION
  56. For the purpose of this program it's not sufficient to know the polyhedra
  57. vertexes coordinates. Since the morphing algorithm applies a nonlinear
  58. transformation over the surfaces (faces) of the polyhedron, each face has
  59. to be divided into smaller ones. The morphing algorithm needs to transform
  60. each vertex of these smaller faces individually. It's a very time consoming
  61. task.
  62. In order to reduce calculation overload, and since all the macro faces of
  63. the polyhedron are transformed by the same way, the generation is made by
  64. creating only one face of the polyhedron, morphing it and then rotating it
  65. around the polyhedron center.
  66. What we need to know is the face radius of the polyhedron (the radius of
  67. the inscribed sphere) and the angle between the center of two adjacent
  68. faces using the center of the sphere as the angle's vertex.
  69. The face radius of the regular polyhedra are known values which I decided
  70. to not waste my time calculating. Following is a table of face radius for
  71. the regular polyhedra with edge length = 1:
  72. TETRAHEDRON : 1/(2*sqrt(2))/sqrt(3)
  73. CUBE : 1/2
  74. OCTAHEDRON : 1/sqrt(6)
  75. DODECAHEDRON : T^2 * sqrt((T+2)/5) / 2 -> where T=(sqrt(5)+1)/2
  76. ICOSAHEDRON : (3*sqrt(3)+sqrt(15))/12
  77. I've not found any reference about the mentioned angles, so I needed to
  78. calculate them, not a trivial task until I figured out how :)
  79. Curiously these angles are the same for the tetrahedron and octahedron.
  80. A way to obtain this value is inscribing the tetrahedron inside the cube
  81. by matching their vertexes. So you'll notice that the remaining unmatched
  82. vertexes are in the same straight line starting in the cube/tetrahedron
  83. center and crossing the center of each tetrahedron's face. At this point
  84. it's easy to obtain the bigger angle of the isosceles triangle formed by
  85. the center of the cube and two opposite vertexes on the same cube face.
  86. The edges of this triangle have the following lenghts: sqrt(2) for the base
  87. and sqrt(3)/2 for the other two other edges. So the angle we want is:
  88. +-----------------------------------------------------------+
  89. | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees |
  90. +-----------------------------------------------------------+
  91. For the cube this angle is obvious, but just for formality it can be
  92. easily obtained because we also know it's isosceles edge lenghts:
  93. sqrt(2)/2 for the base and 1/2 for the other two edges. So the angle we
  94. want is:
  95. +-----------------------------------------------------------+
  96. | 2*ARCSIN((sqrt(2)/2)/1) = 90.000000000000000000 degrees |
  97. +-----------------------------------------------------------+
  98. For the octahedron we use the same idea used for the tetrahedron, but now
  99. we inscribe the cube inside the octahedron so that all cubes's vertexes
  100. matches excatly the center of each octahedron's face. It's now clear that
  101. this angle is the same of the thetrahedron one:
  102. +-----------------------------------------------------------+
  103. | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees |
  104. +-----------------------------------------------------------+
  105. For the dodecahedron it's a little bit harder because it's only relationship
  106. with the cube is useless to us. So we need to solve the problem by another
  107. way. The concept of Face radius also exists on 2D polygons with the name
  108. Edge radius:
  109. Edge Radius For Pentagon (ERp)
  110. ERp = (1/2)/TAN(36 degrees) * VRp = 0.6881909602355867905
  111. (VRp is the pentagon's vertex radio).
  112. Face Radius For Dodecahedron
  113. FRd = T^2 * sqrt((T+2)/5) / 2 = 1.1135163644116068404
  114. Why we need ERp? Well, ERp and FRd segments forms a 90 degrees angle,
  115. completing this triangle, the lesser angle is a half of the angle we are
  116. looking for, so this angle is:
  117. +-----------------------------------------------------------+
  118. | 2*ARCTAN(ERp/FRd) = 63.434948822922009981 degrees |
  119. +-----------------------------------------------------------+
  120. For the icosahedron we can use the same method used for dodecahedron (well
  121. the method used for dodecahedron may be used for all regular polyhedra)
  122. Edge Radius For Triangle (this one is well known: 1/3 of the triangle height)
  123. ERt = sin(60)/3 = sqrt(3)/6 = 0.2886751345948128655
  124. Face Radius For Icosahedron
  125. FRi= (3*sqrt(3)+sqrt(15))/12 = 0.7557613140761707538
  126. So the angle is:
  127. +-----------------------------------------------------------+
  128. | 2*ARCTAN(ERt/FRi) = 41.810314895778596167 degrees |
  129. +-----------------------------------------------------------+
  130. }
  131. uses
  132. GL,GLUT;
  133. type
  134. float = single;
  135. const
  136. Scale = 0.3;
  137. // #define sqr(A) ((A)*(A))
  138. // Increasing this values produces better image quality, the price is speed.
  139. // Very low values produces erroneous/incorrect plotting
  140. tetradivisions = 23;
  141. cubedivisions = 20;
  142. octadivisions = 21;
  143. dodecadivisions = 10;
  144. icodivisions = 15;
  145. tetraangle = 109.47122063449069174;
  146. cubeangle = 90.000000000000000000;
  147. octaangle = 109.47122063449069174;
  148. dodecaangle = 63.434948822922009981;
  149. icoangle = 41.810314895778596167;
  150. //#define Pi 3.1415926535897932385
  151. SQRT2 = 1.4142135623730951455;
  152. SQRT3 = 1.7320508075688771932;
  153. SQRT5 = 2.2360679774997898051;
  154. SQRT6 = 2.4494897427831778813;
  155. SQRT15 = 3.8729833462074170214;
  156. cossec36_2 = 0.8506508083520399322;
  157. cos72 = 0.3090169943749474241;
  158. sin72 = 0.9510565162951535721;
  159. cos36 = 0.8090169943749474241;
  160. sin36 = 0.5877852522924731292;
  161. {*************************************************************************}
  162. const
  163. mono : boolean=false;
  164. smooth : boolean=true;
  165. var
  166. WindH,WindW : GLint;
  167. step,seno : GLFloat;
  168. _object : glint;
  169. edgedivisions : glint;
  170. draw_object : procedure;
  171. Magnitude : glfloat;
  172. MaterialColor : array[0..19] of pglfloat;
  173. const
  174. front_shininess : array[0..0] of glfloat = (60.0);
  175. front_specular : array[0..3] of glfloat = ( 0.7, 0.7, 0.7, 1.0 );
  176. ambient : array[0..3] of glfloat = ( 0.0, 0.0, 0.0, 1.0 );
  177. diffuse : array[0..3] of glfloat = ( 1.0, 1.0, 1.0, 1.0 );
  178. position0 : array[0..3] of glfloat = ( 1.0, 1.0, 1.0, 0.0 );
  179. position1 : array[0..3] of glfloat = (-1.0,-1.0, 1.0, 0.0 );
  180. lmodel_ambient : array[0..3] of glfloat = ( 0.5, 0.5, 0.5, 1.0 );
  181. lmodel_twoside : array[0..0] of glfloat = (GL_TRUE);
  182. MaterialRed : array[0..3] of glfloat = ( 0.7, 0.0, 0.0, 1.0 );
  183. MaterialGreen : array[0..3] of glfloat = ( 0.1, 0.5, 0.2, 1.0 );
  184. MaterialBlue : array[0..3] of glfloat = ( 0.0, 0.0, 0.7, 1.0 );
  185. MaterialCyan : array[0..3] of glfloat = ( 0.2, 0.5, 0.7, 1.0 );
  186. MaterialYellow : array[0..3] of glfloat = ( 0.7, 0.7, 0.0, 1.0 );
  187. MaterialMagenta : array[0..3] of glfloat = ( 0.6, 0.2, 0.5, 1.0 );
  188. MaterialWhite : array[0..3] of glfloat = ( 0.7, 0.7, 0.7, 1.0 );
  189. MaterialGray : array[0..3] of glfloat = ( 0.2, 0.2, 0.2, 1.0 );
  190. procedure TRIANGLE(Edge,Amp:GLFloat; Divisions: longint; Z:GLFloat);
  191. var
  192. Xf,Yf,Xa,Yb,Xf2,Yf2 : Extended;
  193. Factor,Factor1,Factor2 : GLfloat;
  194. VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ : GLfloat;
  195. Ax,Ay,Bx : GLfloat;
  196. Ri,Ti : longint;
  197. Vr : GLfloat;
  198. AmpVr2 : GLfloat;
  199. Zf : GLfloat;
  200. begin
  201. Vr:=(Edge)*SQRT3/3;
  202. AmpVr2:=(Amp)/sqr(Vr);
  203. Zf:=(Edge)*(Z);
  204. Ax:=(Edge)*(+0.5/(Divisions));
  205. Ay:=(Edge)*(-SQRT3/(2*Divisions));
  206. Bx:=(Edge)*(-0.5/(Divisions));
  207. for Ri:=1 to Divisions do
  208. begin
  209. glBegin(GL_TRIANGLE_STRIP);
  210. for Ti:=0 to Ri-1 do
  211. begin
  212. Xf:=(Ri-Ti)*Ax + Ti*Bx;
  213. Yf:=Vr+(Ri-Ti)*Ay + Ti*Ay;
  214. Xa:=Xf+0.001; Yb:=Yf+0.001;
  215. Xf2:=sqr(Xf);
  216. Yf2:=sqr(Yf);
  217. Factor:=1-(((Xf2)+(Yf2))*AmpVr2);
  218. Factor1:=1-((sqr(Xa)+Yf2)*AmpVr2);
  219. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  220. VertX:=Factor*Xf; VertY:=Factor*Yf; VertZ:=Factor*Zf;
  221. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Yf-VertY; NeiAZ:=Factor1*Zf-VertZ;
  222. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  223. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  224. glVertex3f(VertX, VertY, VertZ);
  225. Xf:=(Ri-Ti-1)*Ax + Ti*Bx;
  226. Yf:=Vr+(Ri-Ti-1)*Ay + Ti*Ay;
  227. Xa:=Xf+0.001; Yb:=Yf+0.001;
  228. Xf2:=sqr(Xf);
  229. Yf2:=sqr(Yf);
  230. Factor:=1-(((Xf2)+(Yf2))*AmpVr2);
  231. Factor1:=1-((sqr(Xa)+Yf2)*AmpVr2);
  232. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  233. VertX:=Factor*Xf; VertY:=Factor*Yf; VertZ:=Factor*Zf;
  234. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Yf-VertY; NeiAZ:=Factor1*Zf-VertZ;
  235. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  236. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  237. glVertex3f(VertX, VertY, VertZ);
  238. end;
  239. Xf:=Ri*Bx;
  240. Yf:=Vr+Ri*Ay;
  241. Xa:=Xf+0.001; Yb:=Yf+0.001;
  242. Xf2:=sqr(Xf);
  243. Yf2:=sqr(Yf);
  244. Factor:=1-((Xf2+Yf2)*AmpVr2);
  245. Factor1:=1-((sqr(Xa)+Yf2)*AmpVr2);
  246. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  247. VertX:=Factor*Xf; VertY:=Factor*Yf; VertZ:=Factor*Zf;
  248. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Yf-VertY; NeiAZ:=Factor1*Zf-VertZ;
  249. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  250. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  251. glVertex3f(VertX, VertY, VertZ);
  252. glEnd();
  253. end;
  254. end;
  255. procedure SQUARE(Edge,Amp:GLFloat; Divisions: longint; Z:GLFloat);
  256. var
  257. Xi,Yi : longint;
  258. Xf,Yf,Y,Y2,Xf2,Yf2,Xa,Yb : GLfloat;
  259. Factor,Factor1,Factor2 : GLfloat;
  260. VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ : GLfloat;
  261. AmpVr2 : GLfloat;
  262. Zf : GLfloat;
  263. begin
  264. AmpVr2:=(Amp)/sqr((Edge)*SQRT2/2);
  265. Zf:=(Edge)*(Z);
  266. for Yi:=0 to Divisions-1 do
  267. begin
  268. Yf:=-((Edge)/2.0) + (Yi)/(Divisions)*(Edge);
  269. Yf2:=sqr(Yf);
  270. Y:=Yf+1.0/(Divisions)*(Edge);
  271. Y2:=sqr(Y);
  272. glBegin(GL_QUAD_STRIP);
  273. for Xi:=0 to Divisions do
  274. begin
  275. Xf:=-((Edge)/2.0) + (Xi)/(Divisions)*(Edge);
  276. Xf2:=sqr(Xf);
  277. Xa:=Xf+0.001; Yb:=Y+0.001;
  278. Factor:=1-((Xf2+Y2)*AmpVr2);
  279. Factor1:=1-((sqr(Xa)+Y2)*AmpVr2);
  280. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  281. VertX:=Factor*Xf; VertY:=Factor*Y; VertZ:=Factor*Zf;
  282. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Y-VertY; NeiAZ:=Factor1*Zf-VertZ;
  283. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  284. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  285. glVertex3f(VertX, VertY, VertZ);
  286. Xa:=Xf+0.001; Yb:=Yf+0.001;
  287. Factor:=1-((Xf2+Yf2)*AmpVr2);
  288. Factor1:=1-((sqr(Xa)+Yf2)*AmpVr2);
  289. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  290. VertX:=Factor*Xf; VertY:=Factor*Yf; VertZ:=Factor*Zf;
  291. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Yf-VertY; NeiAZ:=Factor1*Zf-VertZ;
  292. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  293. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  294. glVertex3f(VertX, VertY, VertZ);
  295. end;
  296. glEnd();
  297. end;
  298. end;
  299. procedure PENTAGON(Edge,Amp:GLFloat; Divisions: longint; Z:GLFloat);
  300. var
  301. Ri,Ti,Fi : longint;
  302. Xf,Yf,Xf2,Yf2,Xa,Yb : GLfloat;
  303. X,Y : array[0..5] of GLFloat;
  304. Factor,Factor1,Factor2 : GLfloat;
  305. VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ : GLfloat;
  306. AmpVr2 : GLfloat;
  307. Zf : GLfloat;
  308. begin
  309. AmpVr2:=(Amp)/sqr((Edge)*cossec36_2);
  310. Zf:=(Edge)*(Z);
  311. for Fi:=0 to 5 do
  312. begin
  313. x[Fi]:=-cos( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge);
  314. y[Fi]:=sin( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge);
  315. end;
  316. for Ri:=1 to Divisions do
  317. begin
  318. for Fi:=0 to 4 do
  319. begin
  320. glBegin(GL_TRIANGLE_STRIP);
  321. for Ti:=0 to Ri-1 do
  322. begin
  323. Xf:=(Ri-Ti)*x[Fi] + Ti*x[Fi+1];
  324. Yf:=(Ri-Ti)*y[Fi] + Ti*y[Fi+1];
  325. Xa:=Xf+0.001; Yb:=Yf+0.001;
  326. Xf2:=sqr(Xf);
  327. Yf2:=sqr(Yf);
  328. Factor:=1-(((Xf2)+(Yf2))*AmpVr2);
  329. Factor1:=1-((sqr(Xa)+Yf2)*AmpVr2);
  330. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  331. VertX:=Factor*Xf; VertY:=Factor*Yf; VertZ:=Factor*Zf;
  332. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Yf-VertY; NeiAZ:=Factor1*Zf-VertZ;
  333. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  334. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  335. glVertex3f(VertX, VertY, VertZ);
  336. Xf:=(Ri-Ti-1)*x[Fi] + Ti*x[Fi+1];
  337. Yf:=(Ri-Ti-1)*y[Fi] + Ti*y[Fi+1];
  338. Xa:=Xf+0.001; Yb:=Yf+0.001;
  339. Xf2:=sqr(Xf);
  340. Yf2:=sqr(Yf);
  341. Factor:=1-(((Xf2)+(Yf2))*AmpVr2);
  342. Factor1:=1-((sqr(Xa)+Yf2)*AmpVr2);
  343. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  344. VertX:=Factor*Xf; VertY:=Factor*Yf; VertZ:=Factor*Zf;
  345. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Yf-VertY; NeiAZ:=Factor1*Zf-VertZ;
  346. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  347. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  348. glVertex3f(VertX, VertY, VertZ);
  349. end;
  350. Xf:=Ri*x[Fi+1];
  351. Yf:=Ri*y[Fi+1];
  352. Xa:=Xf+0.001; Yb:=Yf+0.001;
  353. Xf2:=sqr(Xf);
  354. Yf2:=sqr(Yf);
  355. Factor:=1-(((Xf2)+(Yf2))*AmpVr2);
  356. Factor1:=1-((sqr(Xa)+Yf2)*AmpVr2);
  357. Factor2:=1-((Xf2+sqr(Yb))*AmpVr2);
  358. VertX:=Factor*Xf; VertY:=Factor*Yf; VertZ:=Factor*Zf;
  359. NeiAX:=Factor1*Xa-VertX; NeiAY:=Factor1*Yf-VertY; NeiAZ:=Factor1*Zf-VertZ;
  360. NeiBX:=Factor2*Xf-VertX; NeiBY:=Factor2*Yb-VertY; NeiBZ:=Factor2*Zf-VertZ;
  361. glNormal3f(NeiAY*NeiBZ-NeiAZ*NeiBY,NeiAZ*NeiBX-NeiAX*NeiBZ,NeiAX*NeiBY-NeiAY*NeiBX);
  362. glVertex3f(VertX, VertY, VertZ);
  363. glEnd();
  364. end;
  365. end;
  366. end;
  367. procedure draw_tetra;
  368. var
  369. list : GLuint;
  370. begin
  371. list := glGenLists( 1 );
  372. glNewList( list, GL_COMPILE );
  373. TRIANGLE(2,seno,edgedivisions,0.5/SQRT6);
  374. glEndList();
  375. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
  376. glCallList(list);
  377. glPushMatrix();
  378. glRotatef(180,0,0,1);
  379. glRotatef(-tetraangle,1,0,0);
  380. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
  381. glCallList(list);
  382. glPopMatrix();
  383. glPushMatrix();
  384. glRotatef(180,0,1,0);
  385. glRotatef(-180+tetraangle,0.5,SQRT3/2,0);
  386. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
  387. glCallList(list);
  388. glPopMatrix();
  389. glRotatef(180,0,1,0);
  390. glRotatef(-180+tetraangle,0.5,-SQRT3/2,0);
  391. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
  392. glCallList(list);
  393. glDeleteLists(list,1);
  394. end;
  395. procedure draw_cube;
  396. var
  397. list : GLuint;
  398. begin
  399. list := glGenLists( 1 );
  400. glNewList( list, GL_COMPILE );
  401. SQUARE(2, seno, edgedivisions, 0.5);
  402. glEndList();
  403. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
  404. glCallList(list);
  405. glRotatef(cubeangle,1,0,0);
  406. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
  407. glCallList(list);
  408. glRotatef(cubeangle,1,0,0);
  409. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
  410. glCallList(list);
  411. glRotatef(cubeangle,1,0,0);
  412. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
  413. glCallList(list);
  414. glRotatef(cubeangle,0,1,0);
  415. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
  416. glCallList(list);
  417. glRotatef(2*cubeangle,0,1,0);
  418. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
  419. glCallList(list);
  420. glDeleteLists(list,1);
  421. end;
  422. procedure draw_octa;
  423. var
  424. list : GLuint;
  425. begin
  426. list := glGenLists( 1 );
  427. glNewList( list, GL_COMPILE );
  428. TRIANGLE(2,seno,edgedivisions,1/SQRT6);
  429. glEndList();
  430. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
  431. glCallList(list);
  432. glPushMatrix();
  433. glRotatef(180,0,0,1);
  434. glRotatef(-180+octaangle,1,0,0);
  435. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
  436. glCallList(list);
  437. glPopMatrix();
  438. glPushMatrix();
  439. glRotatef(180,0,1,0);
  440. glRotatef(-octaangle,0.5,SQRT3/2,0);
  441. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
  442. glCallList(list);
  443. glPopMatrix();
  444. glPushMatrix();
  445. glRotatef(180,0,1,0);
  446. glRotatef(-octaangle,0.5,-SQRT3/2,0);
  447. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
  448. glCallList(list);
  449. glPopMatrix();
  450. glRotatef(180,1,0,0);
  451. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
  452. glCallList(list);
  453. glPushMatrix();
  454. glRotatef(180,0,0,1);
  455. glRotatef(-180+octaangle,1,0,0);
  456. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
  457. glCallList(list);
  458. glPopMatrix();
  459. glPushMatrix();
  460. glRotatef(180,0,1,0);
  461. glRotatef(-octaangle,0.5,SQRT3/2,0);
  462. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]);
  463. glCallList(list);
  464. glPopMatrix();
  465. glRotatef(180,0,1,0);
  466. glRotatef(-octaangle,0.5,-SQRT3/2,0);
  467. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]);
  468. glCallList(list);
  469. glDeleteLists(list,1);
  470. end;
  471. procedure draw_dodeca;
  472. const
  473. TAU = ((SQRT5+1)/2);
  474. var
  475. list : GLuint;
  476. begin
  477. list := glGenLists( 1 );
  478. glNewList( list, GL_COMPILE );
  479. PENTAGON(1,seno,edgedivisions,sqr(TAU) * sqrt((TAU+2)/5) / 2);
  480. glEndList();
  481. glPushMatrix();
  482. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
  483. glCallList(list);
  484. glRotatef(180,0,0,1);
  485. glPushMatrix();
  486. glRotatef(-dodecaangle,1,0,0);
  487. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
  488. glCallList(list);
  489. glPopMatrix();
  490. glPushMatrix();
  491. glRotatef(-dodecaangle,cos72,sin72,0);
  492. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
  493. glCallList(list);
  494. glPopMatrix();
  495. glPushMatrix();
  496. glRotatef(-dodecaangle,cos72,-sin72,0);
  497. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
  498. glCallList(list);
  499. glPopMatrix();
  500. glPushMatrix();
  501. glRotatef(dodecaangle,cos36,-sin36,0);
  502. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
  503. glCallList(list);
  504. glPopMatrix();
  505. glRotatef(dodecaangle,cos36,sin36,0);
  506. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
  507. glCallList(list);
  508. glPopMatrix();
  509. glRotatef(180,1,0,0);
  510. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]);
  511. glCallList(list);
  512. glRotatef(180,0,0,1);
  513. glPushMatrix();
  514. glRotatef(-dodecaangle,1,0,0);
  515. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]);
  516. glCallList(list);
  517. glPopMatrix();
  518. glPushMatrix();
  519. glRotatef(-dodecaangle,cos72,sin72,0);
  520. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[8]);
  521. glCallList(list);
  522. glPopMatrix();
  523. glPushMatrix();
  524. glRotatef(-dodecaangle,cos72,-sin72,0);
  525. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[9]);
  526. glCallList(list);
  527. glPopMatrix();
  528. glPushMatrix();
  529. glRotatef(dodecaangle,cos36,-sin36,0);
  530. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[10]);
  531. glCallList(list);
  532. glPopMatrix();
  533. glRotatef(dodecaangle,cos36,sin36,0);
  534. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[11]);
  535. glCallList(list);
  536. glDeleteLists(list,1);
  537. end;
  538. procedure draw_ico;
  539. var
  540. list : GLuint;
  541. begin
  542. list := glGenLists( 1 );
  543. glNewList( list, GL_COMPILE );
  544. TRIANGLE(1.5,seno,edgedivisions,(3*SQRT3+SQRT15)/12);
  545. glEndList();
  546. glPushMatrix();
  547. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
  548. glCallList(list);
  549. glPushMatrix();
  550. glRotatef(180,0,0,1);
  551. glRotatef(-icoangle,1,0,0);
  552. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
  553. glCallList(list);
  554. glPushMatrix();
  555. glRotatef(180,0,1,0);
  556. glRotatef(-180+icoangle,0.5,SQRT3/2,0);
  557. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
  558. glCallList(list);
  559. glPopMatrix();
  560. glRotatef(180,0,1,0);
  561. glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
  562. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
  563. glCallList(list);
  564. glPopMatrix();
  565. glPushMatrix();
  566. glRotatef(180,0,1,0);
  567. glRotatef(-180+icoangle,0.5,SQRT3/2,0);
  568. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
  569. glCallList(list);
  570. glPushMatrix();
  571. glRotatef(180,0,1,0);
  572. glRotatef(-180+icoangle,0.5,SQRT3/2,0);
  573. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
  574. glCallList(list);
  575. glPopMatrix();
  576. glRotatef(180,0,0,1);
  577. glRotatef(-icoangle,1,0,0);
  578. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]);
  579. glCallList(list);
  580. glPopMatrix();
  581. glRotatef(180,0,1,0);
  582. glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
  583. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]);
  584. glCallList(list);
  585. glPushMatrix();
  586. glRotatef(180,0,1,0);
  587. glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
  588. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[8]);
  589. glCallList(list);
  590. glPopMatrix();
  591. glRotatef(180,0,0,1);
  592. glRotatef(-icoangle,1,0,0);
  593. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[9]);
  594. glCallList(list);
  595. glPopMatrix();
  596. glRotatef(180,1,0,0);
  597. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[10]);
  598. glCallList(list);
  599. glPushMatrix();
  600. glRotatef(180,0,0,1);
  601. glRotatef(-icoangle,1,0,0);
  602. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[11]);
  603. glCallList(list);
  604. glPushMatrix();
  605. glRotatef(180,0,1,0);
  606. glRotatef(-180+icoangle,0.5,SQRT3/2,0);
  607. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[12]);
  608. glCallList(list);
  609. glPopMatrix();
  610. glRotatef(180,0,1,0);
  611. glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
  612. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[13]);
  613. glCallList(list);
  614. glPopMatrix();
  615. glPushMatrix();
  616. glRotatef(180,0,1,0);
  617. glRotatef(-180+icoangle,0.5,SQRT3/2,0);
  618. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[14]);
  619. glCallList(list);
  620. glPushMatrix();
  621. glRotatef(180,0,1,0);
  622. glRotatef(-180+icoangle,0.5,SQRT3/2,0);
  623. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[15]);
  624. glCallList(list);
  625. glPopMatrix();
  626. glRotatef(180,0,0,1);
  627. glRotatef(-icoangle,1,0,0);
  628. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[16]);
  629. glCallList(list);
  630. glPopMatrix();
  631. glRotatef(180,0,1,0);
  632. glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
  633. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[17]);
  634. glCallList(list);
  635. glPushMatrix();
  636. glRotatef(180,0,1,0);
  637. glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
  638. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[18]);
  639. glCallList(list);
  640. glPopMatrix();
  641. glRotatef(180,0,0,1);
  642. glRotatef(-icoangle,1,0,0);
  643. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[19]);
  644. glCallList(list);
  645. glDeleteLists(list,1);
  646. end;
  647. procedure do_draw;extdecl
  648. begin
  649. glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
  650. glPushMatrix();
  651. glTranslatef( 0.0, 0.0, -10.0 );
  652. glScalef( Scale*WindH/WindW, Scale, Scale );
  653. glTranslatef(2.5*WindW/WindH*sin(step*1.11),2.5*cos(step*1.25*1.11),0);
  654. glRotatef(step*100,1,0,0);
  655. glRotatef(step*95,0,1,0);
  656. glRotatef(step*90,0,0,1);
  657. seno:=(sin(step)+1.0/3.0)*(4.0/5.0)*Magnitude;
  658. draw_object();
  659. glPopMatrix();
  660. glFlush();
  661. glutSwapBuffers();
  662. step:=step+0.05;
  663. end;
  664. procedure do_idle;extdecl
  665. begin
  666. glutPostRedisplay();
  667. end;
  668. procedure do_reshape(width,height:longint);extdecl
  669. begin
  670. WindW:=width;
  671. WindH:=height;
  672. glViewport(0, 0, width, height);
  673. glMatrixMode(GL_PROJECTION);
  674. glLoadIdentity();
  675. glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 );
  676. glMatrixMode(GL_MODELVIEW);
  677. end;
  678. procedure pinit;
  679. var
  680. loop : longint;
  681. begin
  682. case _object of
  683. 1 :
  684. begin
  685. draw_object:=draw_tetra;
  686. MaterialColor[0]:=@MaterialRed;
  687. MaterialColor[1]:=@MaterialGreen;
  688. MaterialColor[2]:=@MaterialBlue;
  689. MaterialColor[3]:=@MaterialWhite;
  690. edgedivisions:=tetradivisions;
  691. Magnitude:=2.5;
  692. end;
  693. 2:
  694. begin
  695. draw_object:=draw_cube;
  696. MaterialColor[0]:=@MaterialRed;
  697. MaterialColor[1]:=@MaterialGreen;
  698. MaterialColor[2]:=@MaterialCyan;
  699. MaterialColor[3]:=@MaterialMagenta;
  700. MaterialColor[4]:=@MaterialYellow;
  701. MaterialColor[5]:=@MaterialBlue;
  702. edgedivisions:=cubedivisions;
  703. Magnitude:=2.0;
  704. end;
  705. 3:
  706. begin
  707. draw_object:=draw_octa;
  708. MaterialColor[0]:=MaterialRed;
  709. MaterialColor[1]:=MaterialGreen;
  710. MaterialColor[2]:=MaterialBlue;
  711. MaterialColor[3]:=MaterialWhite;
  712. MaterialColor[4]:=MaterialCyan;
  713. MaterialColor[5]:=MaterialMagenta;
  714. MaterialColor[6]:=MaterialGray;
  715. MaterialColor[7]:=MaterialYellow;
  716. edgedivisions:=octadivisions;
  717. Magnitude:=2.5;
  718. end;
  719. 4:
  720. begin
  721. draw_object:=draw_dodeca;
  722. MaterialColor[ 0]:=MaterialRed;
  723. MaterialColor[ 1]:=MaterialGreen;
  724. MaterialColor[ 2]:=MaterialCyan;
  725. MaterialColor[ 3]:=MaterialBlue;
  726. MaterialColor[ 4]:=MaterialMagenta;
  727. MaterialColor[ 5]:=MaterialYellow;
  728. MaterialColor[ 6]:=MaterialGreen;
  729. MaterialColor[ 7]:=MaterialCyan;
  730. MaterialColor[ 8]:=MaterialRed;
  731. MaterialColor[ 9]:=MaterialMagenta;
  732. MaterialColor[10]:=MaterialBlue;
  733. MaterialColor[11]:=MaterialYellow;
  734. edgedivisions:=dodecadivisions;
  735. Magnitude:=2.0;
  736. end;
  737. 5:
  738. begin
  739. draw_object:=draw_ico;
  740. MaterialColor[ 0]:=MaterialRed;
  741. MaterialColor[ 1]:=MaterialGreen;
  742. MaterialColor[ 2]:=MaterialBlue;
  743. MaterialColor[ 3]:=MaterialCyan;
  744. MaterialColor[ 4]:=MaterialYellow;
  745. MaterialColor[ 5]:=MaterialMagenta;
  746. MaterialColor[ 6]:=MaterialRed;
  747. MaterialColor[ 7]:=MaterialGreen;
  748. MaterialColor[ 8]:=MaterialBlue;
  749. MaterialColor[ 9]:=MaterialWhite;
  750. MaterialColor[10]:=MaterialCyan;
  751. MaterialColor[11]:=MaterialYellow;
  752. MaterialColor[12]:=MaterialMagenta;
  753. MaterialColor[13]:=MaterialRed;
  754. MaterialColor[14]:=MaterialGreen;
  755. MaterialColor[15]:=MaterialBlue;
  756. MaterialColor[16]:=MaterialCyan;
  757. MaterialColor[17]:=MaterialYellow;
  758. MaterialColor[18]:=MaterialMagenta;
  759. MaterialColor[19]:=MaterialGray;
  760. edgedivisions:=icodivisions;
  761. Magnitude:=2.5;
  762. end;
  763. end;
  764. if (mono) then
  765. begin
  766. for loop:=0 to 19 do
  767. MaterialColor[loop]:=MaterialGray;
  768. end;
  769. if (smooth) then
  770. glShadeModel( GL_SMOOTH )
  771. else
  772. glShadeModel( GL_FLAT );
  773. end;
  774. procedure do_key(k:char;x,y:integer);extdecl
  775. begin
  776. case k of
  777. '1' : _object:=1;
  778. '2' : _object:=2;
  779. '3' : _object:=3;
  780. '4' : _object:=4;
  781. '5' : _object:=5;
  782. ' ' : mono:=not mono;
  783. #13 : smooth:=not smooth;
  784. #27 : halt(0);
  785. end;
  786. pinit;
  787. end;
  788. begin
  789. if not GLInitialized then
  790. begin
  791. writeln('OpenGL Not Availble');
  792. halt(1);
  793. end;
  794. if not GLUTInitialized then
  795. begin
  796. writeln('GLUT Not Availble');
  797. halt(1);
  798. end;
  799. writeln('Morph 3D - Shows morphing platonic polyhedra');
  800. writeln('Author: Marcelo Fernandes Vianna ([email protected])');
  801. writeln(' [1] - Tetrahedron');
  802. writeln(' [2] - Hexahedron (Cube)');
  803. writeln(' [3] - Octahedron');
  804. writeln(' [4] - Dodecahedron');
  805. writeln(' [5] - Icosahedron');
  806. writeln('[SPACE] - Toggle colored faces');
  807. writeln('[RETURN] - Toggle smooth/flat shading');
  808. writeln(' [ESC] - Quit');
  809. _object:=3;
  810. glutInitWindowPosition(0,0);
  811. glutInitWindowSize(640,480);
  812. glutInitDisplayMode( GLUT_DEPTH + GLUT_DOUBLE + GLUT_RGB );
  813. if (glutCreateWindow('Morph 3D - Shows morphing platonic polyhedra') <= 0) then
  814. halt(1);
  815. glClearDepth(1.0);
  816. glClearColor( 0.0, 0.0, 0.0, 1.0 );
  817. glColor3f( 1.0, 1.0, 1.0 );
  818. glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
  819. glFlush();
  820. glutSwapBuffers();
  821. glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  822. glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  823. glLightfv(GL_LIGHT0, GL_POSITION, position0);
  824. glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
  825. glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
  826. glLightfv(GL_LIGHT1, GL_POSITION, position1);
  827. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  828. glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
  829. glEnable(GL_LIGHTING);
  830. glEnable(GL_LIGHT0);
  831. glEnable(GL_LIGHT1);
  832. glEnable(GL_DEPTH_TEST);
  833. glEnable(GL_NORMALIZE);
  834. glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
  835. glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);
  836. glHint(GL_FOG_HINT, GL_FASTEST);
  837. glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
  838. glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
  839. pinit();
  840. glutReshapeFunc( @do_reshape );
  841. glutKeyboardFunc( @do_key );
  842. glutIdleFunc( @do_idle );
  843. glutDisplayFunc( @do_draw );
  844. glutMainLoop();
  845. end.
  846. {
  847. $Log$
  848. Revision 1.3 2000-09-04 19:37:54 peter
  849. * don't use inline as it's buggy
  850. Revision 1.2 2000/09/03 22:17:17 peter
  851. * merged
  852. Revision 1.1.2.1 2000/09/03 22:10:47 peter
  853. * fixed for win32
  854. Revision 1.1 2000/09/03 21:25:45 peter
  855. * new updated version
  856. * gtkglarea unit and demo
  857. * win32 opengl headers
  858. * morph3d demo
  859. }