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.

terrain.c 14KB

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