Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wave.c 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software and
  5. * its documentation for any purpose is hereby granted without fee, provided
  6. * that (i) the above copyright notices and this permission notice appear in
  7. * all copies of the software and related documentation, and (ii) the name of
  8. * Silicon Graphics may not be used in any advertising or
  9. * publicity relating to the software without the specific, prior written
  10. * permission of Silicon Graphics.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
  13. * ANY KIND,
  14. * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  15. * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
  18. * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  19. * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
  21. * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  22. * OF THIS SOFTWARE.
  23. */
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <stdlib.h>
  27. #include <math.h>
  28. #include <GL/glut.h>
  29. #ifndef PI
  30. #define PI 3.14159265358979323846
  31. #endif
  32. #define GETCOORD(frame, x, y) (&(theMesh.coords[frame*theMesh.numCoords+(x)+(y)*(theMesh.widthX+1)]))
  33. #define GETFACET(frame, x, y) (&(theMesh.facets[frame*theMesh.numFacets+(x)+(y)*theMesh.widthX]))
  34. GLenum rgb, doubleBuffer;
  35. #include "tkmap.c"
  36. GLint colorIndexes1[3];
  37. GLint colorIndexes2[3];
  38. GLenum clearMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
  39. GLenum smooth = GL_FALSE;
  40. GLenum lighting = GL_TRUE;
  41. GLenum depth = GL_TRUE;
  42. GLenum stepMode = GL_FALSE;
  43. GLenum spinMode = GL_FALSE;
  44. GLint contouring = 0;
  45. GLint widthX, widthY;
  46. GLint checkerSize;
  47. float height;
  48. GLint frames, curFrame = 0, nextFrame = 0;
  49. struct facet {
  50. float color[3];
  51. float normal[3];
  52. };
  53. struct coord {
  54. float vertex[3];
  55. float normal[3];
  56. };
  57. struct mesh {
  58. GLint widthX, widthY;
  59. GLint numFacets;
  60. GLint numCoords;
  61. GLint frames;
  62. struct coord *coords;
  63. struct facet *facets;
  64. } theMesh;
  65. GLubyte contourTexture1[] = {
  66. 255, 255, 255, 255,
  67. 255, 255, 255, 255,
  68. 255, 255, 255, 255,
  69. 127, 127, 127, 127,
  70. };
  71. GLubyte contourTexture2[] = {
  72. 255, 255, 255, 255,
  73. 255, 127, 127, 127,
  74. 255, 127, 127, 127,
  75. 255, 127, 127, 127,
  76. };
  77. #if !defined(GLUTCALLBACK)
  78. #define GLUTCALLBACK
  79. #endif
  80. void GLUTCALLBACK glut_post_redisplay_p(void)
  81. {
  82. static double t0 = -1.;
  83. double t, dt;
  84. t = glutGet(GLUT_ELAPSED_TIME) / 1000.;
  85. if (t0 < 0.)
  86. t0 = t;
  87. dt = t - t0;
  88. if (dt < 1./30.)
  89. return;
  90. t0 = t;
  91. glutPostRedisplay();
  92. }
  93. static void Animate(void)
  94. {
  95. struct coord *coord;
  96. struct facet *facet;
  97. float *lastColor;
  98. float *thisColor;
  99. GLint i, j;
  100. glClear(clearMask);
  101. if (nextFrame || !stepMode) {
  102. curFrame++;
  103. }
  104. if (curFrame >= theMesh.frames) {
  105. curFrame = 0;
  106. }
  107. if ((nextFrame || !stepMode) && spinMode) {
  108. glRotatef(5.0, 0.0, 0.0, 1.0);
  109. }
  110. nextFrame = 0;
  111. for (i = 0; i < theMesh.widthX; i++) {
  112. glBegin(GL_QUAD_STRIP);
  113. lastColor = NULL;
  114. for (j = 0; j < theMesh.widthY; j++) {
  115. facet = GETFACET(curFrame, i, j);
  116. if (!smooth && lighting) {
  117. glNormal3fv(facet->normal);
  118. }
  119. if (lighting) {
  120. if (rgb) {
  121. thisColor = facet->color;
  122. glColor3fv(facet->color);
  123. } else {
  124. thisColor = facet->color;
  125. glMaterialfv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES,
  126. facet->color);
  127. }
  128. } else {
  129. if (rgb) {
  130. thisColor = facet->color;
  131. glColor3fv(facet->color);
  132. } else {
  133. thisColor = facet->color;
  134. glIndexf(facet->color[1]);
  135. }
  136. }
  137. if (!lastColor || (thisColor[0] != lastColor[0] && smooth)) {
  138. if (lastColor) {
  139. glEnd();
  140. glBegin(GL_QUAD_STRIP);
  141. }
  142. coord = GETCOORD(curFrame, i, j);
  143. if (smooth && lighting) {
  144. glNormal3fv(coord->normal);
  145. }
  146. glVertex3fv(coord->vertex);
  147. coord = GETCOORD(curFrame, i+1, j);
  148. if (smooth && lighting) {
  149. glNormal3fv(coord->normal);
  150. }
  151. glVertex3fv(coord->vertex);
  152. }
  153. coord = GETCOORD(curFrame, i, j+1);
  154. if (smooth && lighting) {
  155. glNormal3fv(coord->normal);
  156. }
  157. glVertex3fv(coord->vertex);
  158. coord = GETCOORD(curFrame, i+1, j+1);
  159. if (smooth && lighting) {
  160. glNormal3fv(coord->normal);
  161. }
  162. glVertex3fv(coord->vertex);
  163. lastColor = thisColor;
  164. }
  165. glEnd();
  166. }
  167. glFlush();
  168. if (doubleBuffer) {
  169. glutSwapBuffers();
  170. }
  171. }
  172. static void SetColorMap(void)
  173. {
  174. static float green[3] = {0.2, 1.0, 0.2};
  175. static float red[3] = {1.0, 0.2, 0.2};
  176. float *color = 0, percent;
  177. GLint *indexes = 0, entries, i, j;
  178. entries = glutGet(GLUT_WINDOW_COLORMAP_SIZE);
  179. colorIndexes1[0] = 1;
  180. colorIndexes1[1] = 1 + (GLint)((entries - 1) * 0.3);
  181. colorIndexes1[2] = (GLint)((entries - 1) * 0.5);
  182. colorIndexes2[0] = 1 + (GLint)((entries - 1) * 0.5);
  183. colorIndexes2[1] = 1 + (GLint)((entries - 1) * 0.8);
  184. colorIndexes2[2] = entries - 1;
  185. for (i = 0; i < 2; i++) {
  186. switch (i) {
  187. case 0:
  188. color = green;
  189. indexes = colorIndexes1;
  190. break;
  191. case 1:
  192. color = red;
  193. indexes = colorIndexes2;
  194. break;
  195. }
  196. for (j = indexes[0]; j < indexes[1]; j++) {
  197. percent = 0.2 + 0.8 * (j - indexes[0]) /
  198. (float)(indexes[1] - indexes[0]);
  199. glutSetColor(j, percent*color[0], percent*color[1],
  200. percent*color[2]);
  201. }
  202. for (j=indexes[1]; j<=indexes[2]; j++) {
  203. percent = (j - indexes[1]) / (float)(indexes[2] - indexes[1]);
  204. glutSetColor(j, percent*(1-color[0])+color[0],
  205. percent*(1-color[1])+color[1],
  206. percent*(1-color[2])+color[2]);
  207. }
  208. }
  209. }
  210. static void InitMesh(void)
  211. {
  212. struct coord *coord;
  213. struct facet *facet;
  214. float dp1[3], dp2[3];
  215. float *pt1, *pt2, *pt3;
  216. float angle, d, x, y;
  217. GLint numFacets, numCoords, frameNum, i, j;
  218. theMesh.widthX = widthX;
  219. theMesh.widthY = widthY;
  220. theMesh.frames = frames;
  221. numFacets = widthX * widthY;
  222. numCoords = (widthX + 1) * (widthY + 1);
  223. theMesh.numCoords = numCoords;
  224. theMesh.numFacets = numFacets;
  225. theMesh.coords = (struct coord *)malloc(frames*numCoords*
  226. sizeof(struct coord));
  227. theMesh.facets = (struct facet *)malloc(frames*numFacets*
  228. sizeof(struct facet));
  229. if (theMesh.coords == NULL || theMesh.facets == NULL) {
  230. printf("Out of memory.\n");
  231. exit(1);
  232. }
  233. for (frameNum = 0; frameNum < frames; frameNum++) {
  234. for (i = 0; i <= widthX; i++) {
  235. x = i / (float)widthX;
  236. for (j = 0; j <= widthY; j++) {
  237. y = j / (float)widthY;
  238. d = sqrt(x*x+y*y);
  239. if (d == 0.0) {
  240. d = 0.0001;
  241. }
  242. angle = 2 * PI * d + (2 * PI / frames * frameNum);
  243. coord = GETCOORD(frameNum, i, j);
  244. coord->vertex[0] = x - 0.5;
  245. coord->vertex[1] = y - 0.5;
  246. coord->vertex[2] = (height - height * d) * cos(angle);
  247. coord->normal[0] = -(height / d) * x * ((1 - d) * 2 * PI *
  248. sin(angle) + cos(angle));
  249. coord->normal[1] = -(height / d) * y * ((1 - d) * 2 * PI *
  250. sin(angle) + cos(angle));
  251. coord->normal[2] = -1;
  252. d = 1.0 / sqrt(coord->normal[0]*coord->normal[0]+
  253. coord->normal[1]*coord->normal[1]+1);
  254. coord->normal[0] *= d;
  255. coord->normal[1] *= d;
  256. coord->normal[2] *= d;
  257. }
  258. }
  259. for (i = 0; i < widthX; i++) {
  260. for (j = 0; j < widthY; j++) {
  261. facet = GETFACET(frameNum, i, j);
  262. if (((i/checkerSize)%2)^(j/checkerSize)%2) {
  263. if (rgb) {
  264. facet->color[0] = 1.0;
  265. facet->color[1] = 0.2;
  266. facet->color[2] = 0.2;
  267. } else {
  268. facet->color[0] = colorIndexes1[0];
  269. facet->color[1] = colorIndexes1[1];
  270. facet->color[2] = colorIndexes1[2];
  271. }
  272. } else {
  273. if (rgb) {
  274. facet->color[0] = 0.2;
  275. facet->color[1] = 1.0;
  276. facet->color[2] = 0.2;
  277. } else {
  278. facet->color[0] = colorIndexes2[0];
  279. facet->color[1] = colorIndexes2[1];
  280. facet->color[2] = colorIndexes2[2];
  281. }
  282. }
  283. pt1 = GETCOORD(frameNum, i, j)->vertex;
  284. pt2 = GETCOORD(frameNum, i, j+1)->vertex;
  285. pt3 = GETCOORD(frameNum, i+1, j+1)->vertex;
  286. dp1[0] = pt2[0] - pt1[0];
  287. dp1[1] = pt2[1] - pt1[1];
  288. dp1[2] = pt2[2] - pt1[2];
  289. dp2[0] = pt3[0] - pt2[0];
  290. dp2[1] = pt3[1] - pt2[1];
  291. dp2[2] = pt3[2] - pt2[2];
  292. facet->normal[0] = dp1[1] * dp2[2] - dp1[2] * dp2[1];
  293. facet->normal[1] = dp1[2] * dp2[0] - dp1[0] * dp2[2];
  294. facet->normal[2] = dp1[0] * dp2[1] - dp1[1] * dp2[0];
  295. d = 1.0 / sqrt(facet->normal[0]*facet->normal[0]+
  296. facet->normal[1]*facet->normal[1]+
  297. facet->normal[2]*facet->normal[2]);
  298. facet->normal[0] *= d;
  299. facet->normal[1] *= d;
  300. facet->normal[2] *= d;
  301. }
  302. }
  303. }
  304. }
  305. static void InitMaterials(void)
  306. {
  307. static float ambient[] = {0.1, 0.1, 0.1, 1.0};
  308. static float diffuse[] = {0.5, 1.0, 1.0, 1.0};
  309. static float position[] = {90.0, 90.0, 150.0, 0.0};
  310. static float front_mat_shininess[] = {60.0};
  311. static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0};
  312. static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0};
  313. static float back_mat_shininess[] = {60.0};
  314. static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0};
  315. static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0};
  316. static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
  317. static float lmodel_twoside[] = {GL_TRUE};
  318. glMatrixMode(GL_PROJECTION);
  319. gluPerspective(90.0, 1.0, 0.5, 10.0);
  320. glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  321. glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  322. glLightfv(GL_LIGHT0, GL_POSITION, position);
  323. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  324. glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
  325. glEnable(GL_LIGHTING);
  326. glEnable(GL_LIGHT0);
  327. glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);
  328. glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular);
  329. glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse);
  330. glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess);
  331. glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular);
  332. glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse);
  333. if (rgb) {
  334. glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
  335. }
  336. if (rgb) {
  337. glEnable(GL_COLOR_MATERIAL);
  338. } else {
  339. SetColorMap();
  340. }
  341. }
  342. static void InitTexture(void)
  343. {
  344. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  345. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  346. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  347. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  348. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  349. }
  350. static void Init(void)
  351. {
  352. glClearColor(0.0, 0.0, 0.0, 0.0);
  353. glShadeModel(GL_FLAT);
  354. glFrontFace(GL_CW);
  355. glEnable(GL_DEPTH_TEST);
  356. InitMaterials();
  357. InitTexture();
  358. InitMesh();
  359. glMatrixMode(GL_MODELVIEW);
  360. glTranslatef(0.0, 0.4, -1.8);
  361. glScalef(2.0, 2.0, 2.0);
  362. glRotatef(-35.0, 1.0, 0.0, 0.0);
  363. glRotatef(35.0, 0.0, 0.0, 1.0);
  364. }
  365. static void Reshape(int width, int height)
  366. {
  367. glViewport(0, 0, (GLint)width, (GLint)height);
  368. }
  369. static void Key(unsigned char key, int x, int y)
  370. {
  371. switch (key) {
  372. case 27:
  373. exit(1);
  374. case 'c':
  375. contouring++;
  376. if (contouring == 1) {
  377. static GLfloat map[4] = {0, 0, 20, 0};
  378. glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_LUMINANCE,
  379. GL_UNSIGNED_BYTE, (GLvoid *)contourTexture1);
  380. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
  381. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
  382. glTexGenfv(GL_S, GL_OBJECT_PLANE, map);
  383. glTexGenfv(GL_T, GL_OBJECT_PLANE, map);
  384. glEnable(GL_TEXTURE_2D);
  385. glEnable(GL_TEXTURE_GEN_S);
  386. glEnable(GL_TEXTURE_GEN_T);
  387. } else if (contouring == 2) {
  388. static GLfloat map[4] = {0, 0, 20, 0};
  389. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
  390. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
  391. glPushMatrix();
  392. glMatrixMode(GL_MODELVIEW);
  393. glLoadIdentity();
  394. glTexGenfv(GL_S, GL_EYE_PLANE, map);
  395. glTexGenfv(GL_T, GL_EYE_PLANE, map);
  396. glPopMatrix();
  397. } else {
  398. contouring = 0;
  399. glDisable(GL_TEXTURE_GEN_S);
  400. glDisable(GL_TEXTURE_GEN_T);
  401. glDisable(GL_TEXTURE_2D);
  402. }
  403. break;
  404. case 's':
  405. smooth = !smooth;
  406. if (smooth) {
  407. glShadeModel(GL_SMOOTH);
  408. } else {
  409. glShadeModel(GL_FLAT);
  410. }
  411. break;
  412. case 'l':
  413. lighting = !lighting;
  414. if (lighting) {
  415. glEnable(GL_LIGHTING);
  416. glEnable(GL_LIGHT0);
  417. if (rgb) {
  418. glEnable(GL_COLOR_MATERIAL);
  419. }
  420. } else {
  421. glDisable(GL_LIGHTING);
  422. glDisable(GL_LIGHT0);
  423. if (rgb) {
  424. glDisable(GL_COLOR_MATERIAL);
  425. }
  426. }
  427. break;
  428. case 'd':
  429. depth = !depth;
  430. if (depth) {
  431. glEnable(GL_DEPTH_TEST);
  432. clearMask |= GL_DEPTH_BUFFER_BIT;
  433. } else {
  434. glDisable(GL_DEPTH_TEST);
  435. clearMask &= ~GL_DEPTH_BUFFER_BIT;
  436. }
  437. break;
  438. case 32:
  439. stepMode = !stepMode;
  440. if (stepMode) {
  441. glutIdleFunc(0);
  442. } else {
  443. glutIdleFunc(glut_post_redisplay_p);
  444. }
  445. break;
  446. case 'n':
  447. if (stepMode) {
  448. nextFrame = 1;
  449. }
  450. break;
  451. case 'a':
  452. spinMode = !spinMode;
  453. break;
  454. default:
  455. return;
  456. }
  457. glutPostRedisplay();
  458. }
  459. static GLenum Args(int argc, char **argv)
  460. {
  461. GLint i;
  462. rgb = GL_TRUE;
  463. doubleBuffer = GL_TRUE;
  464. frames = 10;
  465. widthX = 10;
  466. widthY = 10;
  467. checkerSize = 2;
  468. height = 0.2;
  469. for (i = 1; i < argc; i++) {
  470. if (strcmp(argv[i], "-ci") == 0) {
  471. rgb = GL_FALSE;
  472. } else if (strcmp(argv[i], "-rgb") == 0) {
  473. rgb = GL_TRUE;
  474. } else if (strcmp(argv[i], "-sb") == 0) {
  475. doubleBuffer = GL_FALSE;
  476. } else if (strcmp(argv[i], "-db") == 0) {
  477. doubleBuffer = GL_TRUE;
  478. } else if (strcmp(argv[i], "-grid") == 0) {
  479. if (i+2 >= argc || argv[i+1][0] == '-' || argv[i+2][0] == '-') {
  480. printf("-grid (No numbers).\n");
  481. return GL_FALSE;
  482. } else {
  483. widthX = atoi(argv[++i]);
  484. widthY = atoi(argv[++i]);
  485. }
  486. } else if (strcmp(argv[i], "-size") == 0) {
  487. if (i+1 >= argc || argv[i+1][0] == '-') {
  488. printf("-checker (No number).\n");
  489. return GL_FALSE;
  490. } else {
  491. checkerSize = atoi(argv[++i]);
  492. }
  493. } else if (strcmp(argv[i], "-wave") == 0) {
  494. if (i+1 >= argc || argv[i+1][0] == '-') {
  495. printf("-wave (No number).\n");
  496. return GL_FALSE;
  497. } else {
  498. height = atof(argv[++i]);
  499. }
  500. } else if (strcmp(argv[i], "-frames") == 0) {
  501. if (i+1 >= argc || argv[i+1][0] == '-') {
  502. printf("-frames (No number).\n");
  503. return GL_FALSE;
  504. } else {
  505. frames = atoi(argv[++i]);
  506. }
  507. } else {
  508. printf("%s (Bad option).\n", argv[i]);
  509. return GL_FALSE;
  510. }
  511. }
  512. return GL_TRUE;
  513. }
  514. int main(int argc, char **argv)
  515. {
  516. GLenum type;
  517. glutInit(&argc, argv);
  518. if (Args(argc, argv) == GL_FALSE) {
  519. exit(1);
  520. }
  521. glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300);
  522. type = GLUT_DEPTH;
  523. type |= (rgb) ? GLUT_RGB : GLUT_INDEX;
  524. type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
  525. glutInitDisplayMode(type);
  526. if (glutCreateWindow("Wave Demo") == GL_FALSE) {
  527. exit(1);
  528. }
  529. InitMap();
  530. Init();
  531. glutReshapeFunc(Reshape);
  532. glutKeyboardFunc(Key);
  533. glutDisplayFunc(Animate);
  534. glutIdleFunc(glut_post_redisplay_p);
  535. glutMainLoop();
  536. return 0;
  537. }