Windows NT 4.0 source code leak
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.

648 lines
16 KiB

4 years ago
  1. /*
  2. * (c) Copyright 1993, Silicon Graphics, Inc.
  3. * ALL RIGHTS RESERVED
  4. * Permission to use, copy, modify, and distribute this software for
  5. * any purpose and without fee is hereby granted, provided that the above
  6. * copyright notice appear in all copies and that both the copyright notice
  7. * and this permission notice appear in supporting documentation, and that
  8. * the name of Silicon Graphics, Inc. not be used in advertising
  9. * or publicity pertaining to distribution of the software without specific,
  10. * written prior permission.
  11. *
  12. * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13. * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14. * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15. * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
  16. * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17. * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18. * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19. * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20. * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
  21. * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22. * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23. * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24. *
  25. * US Government Users Restricted Rights
  26. * Use, duplication, or disclosure by the Government is subject to
  27. * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28. * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29. * clause at DFARS 252.227-7013 and/or in similar or successor
  30. * clauses in the FAR or the DOD or NASA FAR Supplement.
  31. * Unpublished-- rights reserved under the copyright laws of the
  32. * United States. Contractor/manufacturer is Silicon Graphics,
  33. * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
  34. *
  35. * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  36. */
  37. #include <stdio.h>
  38. #include <string.h>
  39. #include <stdlib.h>
  40. #include <math.h>
  41. #include <time.h>
  42. #include <sys\types.h>
  43. #include <sys\timeb.h>
  44. #include "tk.h"
  45. #define PI 3.14159265358979323846
  46. #define GETCOORD(frame, x, y) (&(theMesh.coords[frame*theMesh.numCoords+(x)+(y)*(theMesh.widthX+1)]))
  47. #define GETFACET(frame, x, y) (&(theMesh.facets[frame*theMesh.numFacets+(x)+(y)*theMesh.widthX]))
  48. GLenum rgb, doubleBuffer, directRender;
  49. GLint colorIndexes1[3];
  50. GLint colorIndexes2[3];
  51. GLenum clearMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
  52. GLenum smooth = GL_TRUE;
  53. GLenum lighting = GL_TRUE;
  54. GLenum depth = GL_TRUE;
  55. GLenum stepMode = GL_FALSE;
  56. GLenum spinMode = GL_FALSE;
  57. GLint contouring = 0;
  58. GLint widthX, widthY;
  59. GLint checkerSize;
  60. float height;
  61. GLint frames, curFrame = 0, nextFrame = 0;
  62. GLboolean displayFrameRate = GL_FALSE;
  63. static GLint frameCount = 0;
  64. struct facet {
  65. float color[3];
  66. float normal[3];
  67. };
  68. struct coord {
  69. float vertex[3];
  70. float normal[3];
  71. };
  72. struct mesh {
  73. GLint widthX, widthY;
  74. GLint numFacets;
  75. GLint numCoords;
  76. GLint frames;
  77. struct coord *coords;
  78. struct facet *facets;
  79. } theMesh;
  80. GLubyte contourTexture1[] = {
  81. 255, 255, 255, 255,
  82. 255, 255, 255, 255,
  83. 255, 255, 255, 255,
  84. 127, 127, 127, 127,
  85. };
  86. GLubyte contourTexture2[] = {
  87. 255, 255, 255, 255,
  88. 255, 127, 127, 127,
  89. 255, 127, 127, 127,
  90. 255, 127, 127, 127,
  91. };
  92. static void Animate(void)
  93. {
  94. struct coord *coord;
  95. struct facet *facet;
  96. float *lastColor;
  97. float *thisColor;
  98. GLint i, j;
  99. static struct _timeb thisTime, baseTime;
  100. double elapsed, frameRate, deltat;
  101. glClear(clearMask);
  102. if (nextFrame || !stepMode) {
  103. curFrame++;
  104. }
  105. if (curFrame >= theMesh.frames) {
  106. // mf: do frame rate calcs here
  107. if( !frameCount ) {
  108. _ftime( &baseTime );
  109. }
  110. else {
  111. if( displayFrameRate ) {
  112. _ftime( &thisTime );
  113. elapsed = thisTime.time + thisTime.millitm/1000.0 -
  114. (baseTime.time + baseTime.millitm/1000.0);
  115. if( elapsed == 0.0 )
  116. printf( "Frame rate = unknown\n" );
  117. else {
  118. frameRate = frameCount / elapsed;
  119. printf( "Frame rate = %5.2f fps\n", frameRate );
  120. }
  121. }
  122. }
  123. frameCount += theMesh.frames;
  124. curFrame = 0;
  125. }
  126. if ((nextFrame || !stepMode) && spinMode) {
  127. glRotatef(5.0, 0.0, 0.0, 1.0);
  128. }
  129. nextFrame = 0;
  130. for (i = 0; i < theMesh.widthX; i++) {
  131. glBegin(GL_QUAD_STRIP);
  132. lastColor = NULL;
  133. for (j = 0; j < theMesh.widthY; j++) {
  134. facet = GETFACET(curFrame, i, j);
  135. if (!smooth && lighting) {
  136. glNormal3fv(facet->normal);
  137. }
  138. if (lighting) {
  139. if (rgb) {
  140. thisColor = facet->color;
  141. glColor3fv(facet->color);
  142. } else {
  143. thisColor = facet->color;
  144. glMaterialfv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES,
  145. facet->color);
  146. }
  147. } else {
  148. if (rgb) {
  149. thisColor = facet->color;
  150. glColor3fv(facet->color);
  151. } else {
  152. thisColor = facet->color;
  153. glIndexf(facet->color[1]);
  154. }
  155. }
  156. if (!lastColor || (thisColor[0] != lastColor[0] && smooth)) {
  157. if (lastColor) {
  158. glEnd();
  159. glBegin(GL_QUAD_STRIP);
  160. }
  161. coord = GETCOORD(curFrame, i, j);
  162. if (smooth && lighting) {
  163. glNormal3fv(coord->normal);
  164. }
  165. glVertex3fv(coord->vertex);
  166. coord = GETCOORD(curFrame, i+1, j);
  167. if (smooth && lighting) {
  168. glNormal3fv(coord->normal);
  169. }
  170. glVertex3fv(coord->vertex);
  171. }
  172. coord = GETCOORD(curFrame, i, j+1);
  173. if (smooth && lighting) {
  174. glNormal3fv(coord->normal);
  175. }
  176. glVertex3fv(coord->vertex);
  177. coord = GETCOORD(curFrame, i+1, j+1);
  178. if (smooth && lighting) {
  179. glNormal3fv(coord->normal);
  180. }
  181. glVertex3fv(coord->vertex);
  182. lastColor = thisColor;
  183. }
  184. glEnd();
  185. }
  186. glFlush();
  187. if (doubleBuffer) {
  188. tkSwapBuffers();
  189. }
  190. }
  191. static void SetColorMap(void)
  192. {
  193. static float green[3] = {0.2, 1.0, 0.2};
  194. static float red[3] = {1.0, 0.2, 0.2};
  195. float *color, percent;
  196. GLint *indexes, entries, i, j;
  197. long buf[4];
  198. entries = tkGetColorMapSize();
  199. colorIndexes1[0] = 1;
  200. colorIndexes1[1] = 1 + (GLint)((entries - 1) * 0.3);
  201. colorIndexes1[2] = (GLint)((entries - 1) * 0.5);
  202. colorIndexes2[0] = 1 + (GLint)((entries - 1) * 0.5);
  203. colorIndexes2[1] = 1 + (GLint)((entries - 1) * 0.8);
  204. colorIndexes2[2] = entries - 1;
  205. for (i = 0; i < 2; i++) {
  206. switch (i) {
  207. case 0:
  208. color = green;
  209. indexes = colorIndexes1;
  210. break;
  211. case 1:
  212. color = red;
  213. indexes = colorIndexes2;
  214. break;
  215. }
  216. for (j = indexes[0]; j < indexes[1]; j++) {
  217. percent = 0.2 + 0.8 * (j - indexes[0]) /
  218. (float)(indexes[1] - indexes[0]);
  219. tkSetOneColor(j, percent*color[0], percent*color[1],
  220. percent*color[2]);
  221. }
  222. for (j=indexes[1]; j<=indexes[2]; j++) {
  223. percent = (j - indexes[1]) / (float)(indexes[2] - indexes[1]);
  224. tkSetOneColor(j, percent*(1-color[0])+color[0],
  225. percent*(1-color[1])+color[1],
  226. percent*(1-color[2])+color[2]);
  227. }
  228. }
  229. }
  230. static void InitMesh(void)
  231. {
  232. struct coord *coord;
  233. struct facet *facet;
  234. float dp1[3], dp2[3];
  235. float *pt1, *pt2, *pt3;
  236. float angle, d, x, y;
  237. GLint numFacets, numCoords, frameNum, i, j;
  238. theMesh.widthX = widthX;
  239. theMesh.widthY = widthY;
  240. theMesh.frames = frames;
  241. numFacets = widthX * widthY;
  242. numCoords = (widthX + 1) * (widthY + 1);
  243. theMesh.numCoords = numCoords;
  244. theMesh.numFacets = numFacets;
  245. theMesh.coords = (struct coord *)malloc(frames*numCoords*
  246. sizeof(struct coord));
  247. theMesh.facets = (struct facet *)malloc(frames*numFacets*
  248. sizeof(struct facet));
  249. if (theMesh.coords == NULL || theMesh.facets == NULL) {
  250. printf("Out of memory.\n");
  251. tkQuit();
  252. }
  253. for (frameNum = 0; frameNum < frames; frameNum++) {
  254. for (i = 0; i <= widthX; i++) {
  255. x = i / (float)widthX;
  256. for (j = 0; j <= widthY; j++) {
  257. y = j / (float)widthY;
  258. d = sqrt(x*x+y*y);
  259. if (d == 0.0) {
  260. d = 0.0001;
  261. }
  262. angle = 2 * PI * d + (2 * PI / frames * frameNum);
  263. coord = GETCOORD(frameNum, i, j);
  264. coord->vertex[0] = x - 0.5;
  265. coord->vertex[1] = y - 0.5;
  266. coord->vertex[2] = (height - height * d) * cos(angle);
  267. coord->normal[0] = -(height / d) * x * ((1 - d) * 2 * PI *
  268. sin(angle) + cos(angle));
  269. coord->normal[1] = -(height / d) * y * ((1 - d) * 2 * PI *
  270. sin(angle) + cos(angle));
  271. coord->normal[2] = -1;
  272. d = 1.0 / sqrt(coord->normal[0]*coord->normal[0]+
  273. coord->normal[1]*coord->normal[1]+1);
  274. coord->normal[0] *= d;
  275. coord->normal[1] *= d;
  276. coord->normal[2] *= d;
  277. }
  278. }
  279. for (i = 0; i < widthX; i++) {
  280. for (j = 0; j < widthY; j++) {
  281. facet = GETFACET(frameNum, i, j);
  282. if (((i/checkerSize)%2)^(j/checkerSize)%2) {
  283. if (rgb) {
  284. facet->color[0] = 1.0;
  285. facet->color[1] = 0.2;
  286. facet->color[2] = 0.2;
  287. } else {
  288. facet->color[0] = colorIndexes1[0];
  289. facet->color[1] = colorIndexes1[1];
  290. facet->color[2] = colorIndexes1[2];
  291. }
  292. } else {
  293. if (rgb) {
  294. facet->color[0] = 0.2;
  295. facet->color[1] = 1.0;
  296. facet->color[2] = 0.2;
  297. } else {
  298. facet->color[0] = colorIndexes2[0];
  299. facet->color[1] = colorIndexes2[1];
  300. facet->color[2] = colorIndexes2[2];
  301. }
  302. }
  303. pt1 = GETCOORD(frameNum, i, j)->vertex;
  304. pt2 = GETCOORD(frameNum, i, j+1)->vertex;
  305. pt3 = GETCOORD(frameNum, i+1, j+1)->vertex;
  306. dp1[0] = pt2[0] - pt1[0];
  307. dp1[1] = pt2[1] - pt1[1];
  308. dp1[2] = pt2[2] - pt1[2];
  309. dp2[0] = pt3[0] - pt2[0];
  310. dp2[1] = pt3[1] - pt2[1];
  311. dp2[2] = pt3[2] - pt2[2];
  312. facet->normal[0] = dp1[1] * dp2[2] - dp1[2] * dp2[1];
  313. facet->normal[1] = dp1[2] * dp2[0] - dp1[0] * dp2[2];
  314. facet->normal[2] = dp1[0] * dp2[1] - dp1[1] * dp2[0];
  315. d = 1.0 / sqrt(facet->normal[0]*facet->normal[0]+
  316. facet->normal[1]*facet->normal[1]+
  317. facet->normal[2]*facet->normal[2]);
  318. facet->normal[0] *= d;
  319. facet->normal[1] *= d;
  320. facet->normal[2] *= d;
  321. }
  322. }
  323. }
  324. }
  325. static void InitMaterials(void)
  326. {
  327. static float ambient[] = {0.1, 0.1, 0.1, 1.0};
  328. static float diffuse[] = {0.5, 1.0, 1.0, 1.0};
  329. static float position[] = {90.0, 90.0, 150.0, 0.0};
  330. static float front_mat_shininess[] = {60.0};
  331. static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0};
  332. static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0};
  333. static float back_mat_shininess[] = {60.0};
  334. static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0};
  335. static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0};
  336. static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
  337. static float lmodel_twoside[] = {GL_TRUE};
  338. glMatrixMode(GL_PROJECTION);
  339. gluPerspective(450, 1.0, 0.5, 10.0);
  340. glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  341. glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  342. glLightfv(GL_LIGHT0, GL_POSITION, position);
  343. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  344. glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
  345. glEnable(GL_LIGHTING);
  346. glEnable(GL_LIGHT0);
  347. glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);
  348. glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular);
  349. glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse);
  350. glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess);
  351. glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular);
  352. glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse);
  353. if (rgb) {
  354. glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
  355. }
  356. if (rgb) {
  357. glEnable(GL_COLOR_MATERIAL);
  358. } else {
  359. SetColorMap();
  360. }
  361. }
  362. static void InitTexture(void)
  363. {
  364. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  365. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  366. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  367. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  368. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  369. }
  370. static void Init(void)
  371. {
  372. glClearColor(0.0, 0.0, 0.0, 0.0);
  373. if (smooth) {
  374. glShadeModel(GL_SMOOTH);
  375. } else {
  376. glShadeModel(GL_FLAT);
  377. }
  378. glFrontFace(GL_CW);
  379. glDepthFunc(GL_LEQUAL);
  380. glEnable(GL_DEPTH_TEST);
  381. InitMaterials();
  382. InitTexture();
  383. InitMesh();
  384. glMatrixMode(GL_MODELVIEW);
  385. glTranslatef(0.0, 0.4, -1.8);
  386. glScalef(2.0, 2.0, 2.0);
  387. glRotatef(-35.0, 1.0, 0.0, 0.0);
  388. glRotatef(35.0, 0.0, 0.0, 1.0);
  389. }
  390. static void Reshape(int width, int height)
  391. {
  392. glViewport(0, 0, (GLint)width, (GLint)height);
  393. }
  394. static GLenum Key(int key, GLenum mask)
  395. {
  396. switch (key) {
  397. case TK_ESCAPE:
  398. tkQuit();
  399. case TK_c:
  400. contouring++;
  401. if (contouring == 1) {
  402. static GLfloat map[4] = {0, 0, 20, 0};
  403. glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_LUMINANCE,
  404. GL_UNSIGNED_BYTE, (GLvoid *)contourTexture1);
  405. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
  406. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
  407. glTexGenfv(GL_S, GL_OBJECT_PLANE, map);
  408. glTexGenfv(GL_T, GL_OBJECT_PLANE, map);
  409. glEnable(GL_TEXTURE_2D);
  410. glEnable(GL_TEXTURE_GEN_S);
  411. glEnable(GL_TEXTURE_GEN_T);
  412. } else if (contouring == 2) {
  413. static GLfloat map[4] = {0, 0, 20, 0};
  414. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
  415. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
  416. glPushMatrix();
  417. glMatrixMode(GL_MODELVIEW);
  418. glLoadIdentity();
  419. glTexGenfv(GL_S, GL_EYE_PLANE, map);
  420. glTexGenfv(GL_T, GL_EYE_PLANE, map);
  421. glPopMatrix();
  422. } else {
  423. contouring = 0;
  424. glDisable(GL_TEXTURE_GEN_S);
  425. glDisable(GL_TEXTURE_GEN_T);
  426. glDisable(GL_TEXTURE_2D);
  427. }
  428. break;
  429. case TK_s:
  430. smooth = !smooth;
  431. if (smooth) {
  432. glShadeModel(GL_SMOOTH);
  433. } else {
  434. glShadeModel(GL_FLAT);
  435. }
  436. break;
  437. case TK_l:
  438. lighting = !lighting;
  439. if (lighting) {
  440. glEnable(GL_LIGHTING);
  441. glEnable(GL_LIGHT0);
  442. if (rgb) {
  443. glEnable(GL_COLOR_MATERIAL);
  444. }
  445. } else {
  446. glDisable(GL_LIGHTING);
  447. glDisable(GL_LIGHT0);
  448. if (rgb) {
  449. glDisable(GL_COLOR_MATERIAL);
  450. }
  451. }
  452. break;
  453. case TK_d:
  454. depth = !depth;
  455. if (depth) {
  456. glEnable(GL_DEPTH_TEST);
  457. clearMask |= GL_DEPTH_BUFFER_BIT;
  458. } else {
  459. glDisable(GL_DEPTH_TEST);
  460. clearMask &= ~GL_DEPTH_BUFFER_BIT;
  461. }
  462. break;
  463. case TK_SPACE:
  464. stepMode = !stepMode;
  465. if (stepMode) {
  466. tkIdleFunc(0);
  467. tkDisplayFunc(Animate);
  468. } else {
  469. tkIdleFunc(Animate);
  470. tkDisplayFunc(0);
  471. }
  472. break;
  473. case TK_n:
  474. if (stepMode) {
  475. nextFrame = 1;
  476. }
  477. break;
  478. case TK_f:
  479. displayFrameRate = !displayFrameRate;
  480. frameCount = 0;
  481. break;
  482. case TK_a:
  483. spinMode = !spinMode;
  484. break;
  485. default:
  486. return GL_FALSE;
  487. }
  488. return GL_TRUE;
  489. }
  490. static GLenum Args(int argc, char **argv)
  491. {
  492. GLint i;
  493. rgb = GL_TRUE;
  494. doubleBuffer = GL_TRUE;
  495. directRender = GL_FALSE;
  496. frames = 10;
  497. widthX = 10;
  498. widthY = 10;
  499. checkerSize = 2;
  500. height = 0.2;
  501. for (i = 1; i < argc; i++) {
  502. if (strcmp(argv[i], "-ci") == 0) {
  503. rgb = GL_FALSE;
  504. } else if (strcmp(argv[i], "-rgb") == 0) {
  505. rgb = GL_TRUE;
  506. } else if (strcmp(argv[i], "-sb") == 0) {
  507. doubleBuffer = GL_FALSE;
  508. } else if (strcmp(argv[i], "-db") == 0) {
  509. doubleBuffer = GL_TRUE;
  510. } else if (strcmp(argv[i], "-dr") == 0) {
  511. directRender = GL_TRUE;
  512. } else if (strcmp(argv[i], "-ir") == 0) {
  513. directRender = GL_FALSE;
  514. } else if (strcmp(argv[i], "-grid") == 0) {
  515. if (i+2 >= argc || argv[i+1][0] == '-' || argv[i+2][0] == '-') {
  516. printf("-grid (No numbers).\n");
  517. return GL_FALSE;
  518. } else {
  519. widthX = atoi(argv[++i]);
  520. widthY = atoi(argv[++i]);
  521. }
  522. } else if (strcmp(argv[i], "-size") == 0) {
  523. if (i+1 >= argc || argv[i+1][0] == '-') {
  524. printf("-checker (No number).\n");
  525. return GL_FALSE;
  526. } else {
  527. checkerSize = atoi(argv[++i]);
  528. }
  529. } else if (strcmp(argv[i], "-wave") == 0) {
  530. if (i+1 >= argc || argv[i+1][0] == '-') {
  531. printf("-wave (No number).\n");
  532. return GL_FALSE;
  533. } else {
  534. height = atof(argv[++i]);
  535. }
  536. } else if (strcmp(argv[i], "-frames") == 0) {
  537. if (i+1 >= argc || argv[i+1][0] == '-') {
  538. printf("-frames (No number).\n");
  539. return GL_FALSE;
  540. } else {
  541. frames = atoi(argv[++i]);
  542. }
  543. } else {
  544. printf("%s (Bad option).\n", argv[i]);
  545. return GL_FALSE;
  546. }
  547. }
  548. return GL_TRUE;
  549. }
  550. void main(int argc, char **argv)
  551. {
  552. GLenum type;
  553. if (Args(argc, argv) == GL_FALSE) {
  554. tkQuit();
  555. }
  556. tkInitPosition(10, 30, 300, 300);
  557. type = TK_DEPTH16;
  558. type |= (rgb) ? TK_RGB : TK_INDEX;
  559. type |= (doubleBuffer) ? TK_DOUBLE : TK_SINGLE;
  560. type |= (directRender) ? TK_DIRECT : TK_INDIRECT;
  561. tkInitDisplayMode(type);
  562. if (tkInitWindow("Wave Demo") == GL_FALSE) {
  563. tkQuit();
  564. }
  565. Init();
  566. tkExposeFunc(Reshape);
  567. tkReshapeFunc(Reshape);
  568. tkKeyDownFunc(Key);
  569. tkIdleFunc(Animate);
  570. tkExec();
  571. }