Clone of mesa.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

terrain.c 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /*
  2. * This program is under the GNU GPL.
  3. * Use at your own risk.
  4. *
  5. * written by David Bucciarelli (tech.hmw@plus.it)
  6. * Humanware s.r.l.
  7. *
  8. * based on a Mikael SkiZoWalker's (MoDEL) / France (Skizo@Hol.Fr) demo
  9. */
  10. #include <stdio.h>
  11. #include <math.h>
  12. #include <stdlib.h>
  13. #include <time.h>
  14. #ifdef WIN32
  15. #include <windows.h>
  16. #endif
  17. #include <GL/glut.h>
  18. #ifdef XMESA
  19. #include "GL/xmesa.h"
  20. static int fullscreen = 1;
  21. #endif
  22. #ifndef M_PI
  23. #define M_PI 3.14159265
  24. #endif
  25. #define heightMnt 450
  26. #define lenghtXmnt 62
  27. #define lenghtYmnt 62
  28. #define stepXmnt 96.0
  29. #define stepYmnt 96.0
  30. #define WIDTH 640
  31. #define HEIGHT 480
  32. static GLint T0 = 0;
  33. static GLint Frames = 0;
  34. #define TSCALE 4
  35. #define FOV 85
  36. static GLfloat terrain[256 * 256];
  37. static GLfloat terraincolor[256 * 256][3];
  38. static int win = 0;
  39. static int fog = 1;
  40. static int bfcull = 1;
  41. static int usetex = 1;
  42. static int poutline = 0;
  43. static int help = 1;
  44. static int joyavailable = 0;
  45. static int joyactive = 0;
  46. static float ModZMnt;
  47. static long GlobalMnt = 0;
  48. static int scrwidth = WIDTH;
  49. static int scrheight = HEIGHT;
  50. #define OBSSTARTX 992.0
  51. #define OBSSTARTY 103.0
  52. static float obs[3] = { OBSSTARTX, heightMnt * 1.3, OBSSTARTY };
  53. static float dir[3], v1[2], v2[2];
  54. static float v = 15.0;
  55. static float alpha = 75.0;
  56. static float beta = 90.0;
  57. static void
  58. calcposobs(void)
  59. {
  60. float alpha1, alpha2;
  61. dir[0] = sin(alpha * M_PI / 180.0);
  62. dir[2] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
  63. dir[1] = cos(beta * M_PI / 180.0);
  64. alpha1 = alpha + FOV / 2.0;
  65. v1[0] = sin(alpha1 * M_PI / 180.0);
  66. v1[1] = cos(alpha1 * M_PI / 180.0);
  67. alpha2 = alpha - FOV / 2.0;
  68. v2[0] = sin(alpha2 * M_PI / 180.0);
  69. v2[1] = cos(alpha2 * M_PI / 180.0);
  70. obs[0] += v * dir[0];
  71. obs[1] += v * dir[1];
  72. obs[2] += v * dir[2];
  73. if (obs[1] < 0.0)
  74. obs[1] = 0.0;
  75. }
  76. static void
  77. reshape(int width, int height)
  78. {
  79. scrwidth = width;
  80. scrheight = height;
  81. glViewport(0, 0, (GLint) width, (GLint) height);
  82. glMatrixMode(GL_PROJECTION);
  83. glLoadIdentity();
  84. gluPerspective(50.0, ((GLfloat) width / (GLfloat) height),
  85. lenghtXmnt * stepYmnt * 0.01, lenghtXmnt * stepYmnt * 0.7);
  86. glMatrixMode(GL_MODELVIEW);
  87. glLoadIdentity();
  88. }
  89. static int
  90. clipstrip(float y, float *start, float *end)
  91. {
  92. float x1, x2, t1, t2, tmp;
  93. if (v1[1] == 0.0) {
  94. t1 = 0.0;
  95. x1 = -HUGE_VAL;
  96. }
  97. else {
  98. t1 = y / v1[1];
  99. x1 = t1 * v1[0];
  100. }
  101. if (v2[1] == 0.0) {
  102. t2 = 0.0;
  103. x2 = HUGE_VAL;
  104. }
  105. else {
  106. t2 = y / v2[1];
  107. x2 = t2 * v2[0];
  108. }
  109. if (((x1 < -(lenghtXmnt * stepXmnt) / 2) && (t2 <= 0.0)) ||
  110. ((t1 <= 0.0) && (x2 > (lenghtXmnt * stepXmnt) / 2)) ||
  111. ((t1 < 0.0) && (t2 < 0.0)))
  112. return 0;
  113. if ((t1 == 0.0) && (t2 == 0.0)) {
  114. if ((v1[0] < 0.0) && (v1[1] > 0.0) && (v2[0] < 0.0) && (v2[1] < 0.0)) {
  115. *start = -(lenghtXmnt * stepXmnt) / 2;
  116. *end = stepXmnt;
  117. return 1;
  118. }
  119. else {
  120. if ((v1[0] > 0.0) && (v1[1] < 0.0) && (v2[0] > 0.0) && (v2[1] > 0.0)) {
  121. *start = -stepXmnt;
  122. *end = (lenghtXmnt * stepXmnt) / 2;
  123. return 1;
  124. }
  125. else
  126. return 0;
  127. }
  128. }
  129. else {
  130. if (t2 < 0.0) {
  131. if (x1 < 0.0)
  132. x2 = -(lenghtXmnt * stepXmnt) / 2;
  133. else
  134. x2 = (lenghtXmnt * stepXmnt) / 2;
  135. }
  136. if (t1 < 0.0) {
  137. if (x2 < 0.0)
  138. x1 = -(lenghtXmnt * stepXmnt) / 2;
  139. else
  140. x1 = (lenghtXmnt * stepXmnt) / 2;
  141. }
  142. }
  143. if (x1 > x2) {
  144. tmp = x1;
  145. x1 = x2;
  146. x2 = tmp;
  147. }
  148. x1 -= stepXmnt;
  149. if (x1 < -(lenghtXmnt * stepXmnt) / 2)
  150. x1 = -(lenghtXmnt * stepXmnt) / 2;
  151. x2 += stepXmnt;
  152. if (x2 > (lenghtXmnt * stepXmnt) / 2)
  153. x2 = (lenghtXmnt * stepXmnt) / 2;
  154. *start = ((int) (x1 / stepXmnt)) * stepXmnt;
  155. *end = ((int) (x2 / stepXmnt)) * stepXmnt;
  156. return 1;
  157. }
  158. static void
  159. printstring(void *font, char *string)
  160. {
  161. int len, i;
  162. len = (int) strlen(string);
  163. for (i = 0; i < len; i++)
  164. glutBitmapCharacter(font, string[i]);
  165. }
  166. static void
  167. printhelp(void)
  168. {
  169. glEnable(GL_BLEND);
  170. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  171. glColor4f(0.0, 0.0, 0.0, 0.5);
  172. glRecti(40, 40, 600, 440);
  173. glDisable(GL_BLEND);
  174. glColor3f(1.0, 0.0, 0.0);
  175. glRasterPos2i(300, 420);
  176. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Help");
  177. glRasterPos2i(60, 390);
  178. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "h - Togle Help");
  179. glRasterPos2i(60, 360);
  180. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "t - Togle Textures");
  181. glRasterPos2i(60, 330);
  182. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "f - Togle Fog");
  183. glRasterPos2i(60, 300);
  184. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "p - Wire frame");
  185. glRasterPos2i(60, 270);
  186. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Togle Back face culling");
  187. glRasterPos2i(60, 240);
  188. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Arrow Keys - Rotate");
  189. glRasterPos2i(60, 210);
  190. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "a - Increase velocity");
  191. glRasterPos2i(60, 180);
  192. printstring(GLUT_BITMAP_TIMES_ROMAN_24, "z - Decrease velocity");
  193. glRasterPos2i(60, 150);
  194. if (joyavailable)
  195. printstring(GLUT_BITMAP_TIMES_ROMAN_24,
  196. "j - Togle jostick control (Joystick control available)");
  197. else
  198. printstring(GLUT_BITMAP_TIMES_ROMAN_24,
  199. "(No Joystick control available)");
  200. }
  201. static void
  202. drawterrain(void)
  203. {
  204. int h, i, idx, ox, oy;
  205. float j, k, start, end;
  206. ox = (int) (obs[0] / stepXmnt);
  207. oy = (int) (obs[2] / stepYmnt);
  208. GlobalMnt = ((ox * TSCALE) & 255) + ((oy * TSCALE) & 255) * 256;
  209. glPushMatrix();
  210. glTranslatef((float) ox * stepXmnt, 0, (float) oy * stepYmnt);
  211. for (h = 0, k = -(lenghtYmnt * stepYmnt) / 2; h < lenghtYmnt;
  212. k += stepYmnt, h++) {
  213. if (!clipstrip(k, &start, &end))
  214. continue;
  215. glBegin(GL_TRIANGLE_STRIP); /* I hope that the optimizer will be able to improve this code */
  216. for (i = (int) (lenghtXmnt / 2 + start / stepXmnt), j = start; j <= end;
  217. j += stepXmnt, i++) {
  218. idx = (i * TSCALE + h * 256 * TSCALE + GlobalMnt) & 65535;
  219. glColor3fv(terraincolor[idx]);
  220. glTexCoord2f((ox + i) / 8.0, (oy + h) / 8.0);
  221. glVertex3f(j, terrain[idx], k);
  222. idx =
  223. (i * TSCALE + h * 256 * TSCALE + 256 * TSCALE +
  224. GlobalMnt) & 65535;
  225. glColor3fv(terraincolor[idx]);
  226. glTexCoord2f((ox + i) / 8.0, (oy + h + 1) / 8.0);
  227. glVertex3f(j, terrain[idx], k + stepYmnt);
  228. }
  229. glEnd();
  230. }
  231. glDisable(GL_CULL_FACE);
  232. glDisable(GL_TEXTURE_2D);
  233. glEnable(GL_BLEND);
  234. glBegin(GL_QUADS);
  235. glColor4f(0.1, 0.7, 1.0, 0.4);
  236. glVertex3f(-(lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
  237. -(lenghtYmnt * stepYmnt) / 2.0);
  238. glVertex3f(-(lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
  239. (lenghtYmnt * stepYmnt) / 2.0);
  240. glVertex3f((lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
  241. (lenghtYmnt * stepYmnt) / 2.0);
  242. glVertex3f((lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
  243. -(lenghtYmnt * stepYmnt) / 2.0);
  244. glEnd();
  245. glDisable(GL_BLEND);
  246. if (bfcull)
  247. glEnable(GL_CULL_FACE);
  248. glEnable(GL_TEXTURE_2D);
  249. glPopMatrix();
  250. }
  251. static void
  252. dojoy(void)
  253. {
  254. #ifdef WIN32
  255. static UINT max[2] = { 0, 0 };
  256. static UINT min[2] = { 0xffffffff, 0xffffffff }, center[2];
  257. MMRESULT res;
  258. JOYINFO joy;
  259. res = joyGetPos(JOYSTICKID1, &joy);
  260. if (res == JOYERR_NOERROR) {
  261. joyavailable = 1;
  262. if (max[0] < joy.wXpos)
  263. max[0] = joy.wXpos;
  264. if (min[0] > joy.wXpos)
  265. min[0] = joy.wXpos;
  266. center[0] = (max[0] + min[0]) / 2;
  267. if (max[1] < joy.wYpos)
  268. max[1] = joy.wYpos;
  269. if (min[1] > joy.wYpos)
  270. min[1] = joy.wYpos;
  271. center[1] = (max[1] + min[1]) / 2;
  272. if (joyactive) {
  273. if (fabs(center[0] - (float) joy.wXpos) > 0.1 * (max[0] - min[0]))
  274. alpha +=
  275. 2.5 * (center[0] - (float) joy.wXpos) / (max[0] - min[0]);
  276. if (fabs(center[1] - (float) joy.wYpos) > 0.1 * (max[1] - min[1]))
  277. beta += 2.5 * (center[1] - (float) joy.wYpos) / (max[1] - min[1]);
  278. if (joy.wButtons & JOY_BUTTON1)
  279. v += 0.5;
  280. if (joy.wButtons & JOY_BUTTON2)
  281. v -= 0.5;
  282. }
  283. }
  284. else
  285. joyavailable = 0;
  286. #endif
  287. }
  288. static void
  289. drawscene(void)
  290. {
  291. static char frbuf[80] = "";
  292. dojoy();
  293. glShadeModel(GL_SMOOTH);
  294. glEnable(GL_DEPTH_TEST);
  295. if (usetex)
  296. glEnable(GL_TEXTURE_2D);
  297. else
  298. glDisable(GL_TEXTURE_2D);
  299. if (fog)
  300. glEnable(GL_FOG);
  301. else
  302. glDisable(GL_FOG);
  303. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  304. glPushMatrix();
  305. calcposobs();
  306. gluLookAt(obs[0], obs[1], obs[2],
  307. obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
  308. 0.0, 1.0, 0.0);
  309. drawterrain();
  310. glPopMatrix();
  311. glDisable(GL_TEXTURE_2D);
  312. glDisable(GL_DEPTH_TEST);
  313. glDisable(GL_FOG);
  314. glShadeModel(GL_FLAT);
  315. glMatrixMode(GL_PROJECTION);
  316. glLoadIdentity();
  317. glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
  318. glMatrixMode(GL_MODELVIEW);
  319. glLoadIdentity();
  320. glColor3f(1.0, 0.0, 0.0);
  321. glRasterPos2i(10, 10);
  322. printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
  323. glRasterPos2i(350, 470);
  324. printstring(GLUT_BITMAP_HELVETICA_10,
  325. "Terrain V1.2 Written by David Bucciarelli (tech.hmw@plus.it)");
  326. glRasterPos2i(434, 457);
  327. printstring(GLUT_BITMAP_HELVETICA_10,
  328. "Based on a Mickael's demo (Skizo@Hol.Fr)");
  329. if (help)
  330. printhelp();
  331. reshape(scrwidth, scrheight);
  332. glutSwapBuffers();
  333. Frames++;
  334. {
  335. GLint t = glutGet(GLUT_ELAPSED_TIME);
  336. if (t - T0 >= 2000) {
  337. GLfloat seconds = (t - T0) / 1000.0;
  338. GLfloat fps = Frames / seconds;
  339. sprintf(frbuf, "Frame rate: %f", fps);
  340. T0 = t;
  341. Frames = 0;
  342. }
  343. }
  344. }
  345. static void
  346. key(unsigned char k, int x, int y)
  347. {
  348. switch (k) {
  349. case 27:
  350. exit(0);
  351. break;
  352. case 'a':
  353. v += 0.5;
  354. break;
  355. case 'z':
  356. v -= 0.5;
  357. break;
  358. case 'p':
  359. if (poutline) {
  360. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  361. poutline = 0;
  362. }
  363. else {
  364. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  365. poutline = 1;
  366. }
  367. break;
  368. case 'j':
  369. joyactive = (!joyactive);
  370. break;
  371. case 'h':
  372. help = (!help);
  373. break;
  374. case 'f':
  375. fog = (!fog);
  376. break;
  377. case 't':
  378. usetex = (!usetex);
  379. break;
  380. case 'b':
  381. if (bfcull) {
  382. glDisable(GL_CULL_FACE);
  383. bfcull = 0;
  384. }
  385. else {
  386. glEnable(GL_CULL_FACE);
  387. bfcull = 1;
  388. }
  389. break;
  390. #ifdef XMESA
  391. case ' ':
  392. XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
  393. fullscreen = (!fullscreen);
  394. break;
  395. #endif
  396. }
  397. }
  398. static void
  399. special(int k, int x, int y)
  400. {
  401. switch (k) {
  402. case GLUT_KEY_LEFT:
  403. alpha += 2.0;
  404. break;
  405. case GLUT_KEY_RIGHT:
  406. alpha -= 2.0;
  407. break;
  408. case GLUT_KEY_DOWN:
  409. beta -= 2.0;
  410. break;
  411. case GLUT_KEY_UP:
  412. beta += 2.0;
  413. break;
  414. }
  415. }
  416. static void
  417. calccolor(GLfloat height, GLfloat c[3])
  418. {
  419. GLfloat color[4][3] = {
  420. {1.0, 1.0, 1.0},
  421. {0.0, 0.8, 0.0},
  422. {1.0, 1.0, 0.3},
  423. {0.0, 0.0, 0.8}
  424. };
  425. GLfloat fact;
  426. height = height * (1.0 / 255.0);
  427. if (height >= 0.9) {
  428. c[0] = color[0][0];
  429. c[1] = color[0][1];
  430. c[2] = color[0][2];
  431. return;
  432. }
  433. if ((height < 0.9) && (height >= 0.7)) {
  434. fact = (height - 0.7) * 5.0;
  435. c[0] = fact * color[0][0] + (1.0 - fact) * color[1][0];
  436. c[1] = fact * color[0][1] + (1.0 - fact) * color[1][1];
  437. c[2] = fact * color[0][2] + (1.0 - fact) * color[1][2];
  438. return;
  439. }
  440. if ((height < 0.7) && (height >= 0.6)) {
  441. fact = (height - 0.6) * 10.0;
  442. c[0] = fact * color[1][0] + (1.0 - fact) * color[2][0];
  443. c[1] = fact * color[1][1] + (1.0 - fact) * color[2][1];
  444. c[2] = fact * color[1][2] + (1.0 - fact) * color[2][2];
  445. return;
  446. }
  447. if ((height < 0.6) && (height >= 0.5)) {
  448. fact = (height - 0.5) * 10.0;
  449. c[0] = fact * color[2][0] + (1.0 - fact) * color[3][0];
  450. c[1] = fact * color[2][1] + (1.0 - fact) * color[3][1];
  451. c[2] = fact * color[2][2] + (1.0 - fact) * color[3][2];
  452. return;
  453. }
  454. c[0] = color[3][0];
  455. c[1] = color[3][1];
  456. c[2] = color[3][2];
  457. }
  458. static void
  459. loadpic(void)
  460. {
  461. GLubyte bufferter[256 * 256], terrainpic[256 * 256];
  462. FILE *FilePic;
  463. int i, tmp;
  464. GLenum gluerr;
  465. if ((FilePic = fopen("terrain.dat", "r")) == NULL) {
  466. fprintf(stderr, "Error loading terrain.dat\n");
  467. exit(-1);
  468. }
  469. fread(bufferter, 256 * 256, 1, FilePic);
  470. fclose(FilePic);
  471. for (i = 0; i < (256 * 256); i++) {
  472. terrain[i] = (bufferter[i] * (heightMnt / 255.0f));
  473. calccolor((GLfloat) bufferter[i], terraincolor[i]);
  474. tmp = (((int) bufferter[i]) + 96);
  475. terrainpic[i] = (tmp > 255) ? 255 : tmp;
  476. }
  477. glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  478. if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, 1, 256, 256, GL_LUMINANCE,
  479. GL_UNSIGNED_BYTE,
  480. (GLvoid *) (&terrainpic[0])))) {
  481. fprintf(stderr, "GLULib%s\n", gluErrorString(gluerr));
  482. exit(-1);
  483. }
  484. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  485. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  486. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
  487. GL_LINEAR_MIPMAP_LINEAR);
  488. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  489. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  490. glEnable(GL_TEXTURE_2D);
  491. }
  492. static void
  493. init(void)
  494. {
  495. float fogcolor[4] = { 0.6, 0.7, 0.7, 1.0 };
  496. glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]);
  497. glClearDepth(1.0);
  498. glDepthFunc(GL_LEQUAL);
  499. glShadeModel(GL_SMOOTH);
  500. glEnable(GL_DEPTH_TEST);
  501. glEnable(GL_CULL_FACE);
  502. glDisable(GL_BLEND);
  503. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  504. glEnable(GL_FOG);
  505. glFogi(GL_FOG_MODE, GL_EXP2);
  506. glFogfv(GL_FOG_COLOR, fogcolor);
  507. glFogf(GL_FOG_DENSITY, 0.0007);
  508. #ifdef FX
  509. glHint(GL_FOG_HINT, GL_NICEST);
  510. #endif
  511. reshape(scrwidth, scrheight);
  512. }
  513. int
  514. main(int ac, char **av)
  515. {
  516. glutInitWindowPosition(0, 0);
  517. glutInitWindowSize(WIDTH, HEIGHT);
  518. glutInit(&ac, av);
  519. glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
  520. if (!(win = glutCreateWindow("Terrain"))) {
  521. fprintf(stderr, "Error, couldn't open window\n");
  522. return -1;
  523. }
  524. ModZMnt = 0.0f;
  525. loadpic();
  526. init();
  527. #ifndef FX
  528. glDisable(GL_TEXTURE_2D);
  529. usetex = 0;
  530. #endif
  531. glutReshapeFunc(reshape);
  532. glutDisplayFunc(drawscene);
  533. glutKeyboardFunc(key);
  534. glutSpecialFunc(special);
  535. glutIdleFunc(drawscene);
  536. glutMainLoop();
  537. return 0;
  538. }