Source code of Windows XP (NT5)
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.

687 lines
17 KiB

  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 <gldd.h>
  45. #include <gl/glu.h>
  46. #pragma warning(disable:4244)
  47. #define PI 3.14159265358979323846
  48. #define GETCOORD(frame, x, y) (&(theMesh.coords[frame*theMesh.numCoords+(x)+(y)*(theMesh.widthX+1)]))
  49. #define GETFACET(frame, x, y) (&(theMesh.facets[frame*theMesh.numFacets+(x)+(y)*theMesh.widthX]))
  50. GLenum rgb, doubleBuffer, directRender;
  51. GLenum videoMemory, noSwap, noClear, fullScreen, useMcd, modeX;
  52. int fullWidth, fullHeight, fullDepth;
  53. GLint colorIndexes1[3];
  54. GLint colorIndexes2[3];
  55. GLenum clearMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
  56. GLenum smooth = GL_TRUE;
  57. GLenum lighting = GL_TRUE;
  58. GLenum depth = GL_TRUE;
  59. GLenum stepMode = GL_FALSE;
  60. GLenum spinMode = GL_FALSE;
  61. GLint contouring = 0;
  62. GLint widthX, widthY;
  63. GLint checkerSize;
  64. float height;
  65. GLint frames, curFrame = 0, nextFrame = 0;
  66. GLboolean displayFrameRate = GL_FALSE;
  67. static GLint frameCount = 0;
  68. struct facet {
  69. float color[3];
  70. float normal[3];
  71. };
  72. struct coord {
  73. float vertex[3];
  74. float normal[3];
  75. };
  76. struct mesh {
  77. GLint widthX, widthY;
  78. GLint numFacets;
  79. GLint numCoords;
  80. GLint frames;
  81. struct coord *coords;
  82. struct facet *facets;
  83. } theMesh;
  84. GLubyte contourTexture1[] = {
  85. 255, 255, 255, 255,
  86. 255, 255, 255, 255,
  87. 255, 255, 255, 255,
  88. 127, 127, 127, 127,
  89. };
  90. GLubyte contourTexture2[] = {
  91. 255, 255, 255, 255,
  92. 255, 127, 127, 127,
  93. 255, 127, 127, 127,
  94. 255, 127, 127, 127,
  95. };
  96. GLDDWINDOW gwMain = NULL;
  97. void Quit(void)
  98. {
  99. if (gwMain != NULL)
  100. {
  101. glddDestroyWindow(gwMain);
  102. }
  103. exit(1);
  104. }
  105. static void Animate(GLDDWINDOW gw)
  106. {
  107. struct coord *coord;
  108. struct facet *facet;
  109. float *lastColor;
  110. float *thisColor;
  111. GLint i, j;
  112. static struct _timeb thisTime, baseTime;
  113. double elapsed, frameRate, deltat;
  114. if (!noClear)
  115. {
  116. glClear(clearMask);
  117. }
  118. if (nextFrame || !stepMode) {
  119. curFrame++;
  120. }
  121. if (curFrame >= theMesh.frames) {
  122. // mf: do frame rate calcs here
  123. if( !frameCount ) {
  124. _ftime( &baseTime );
  125. }
  126. else {
  127. if( displayFrameRate ) {
  128. _ftime( &thisTime );
  129. elapsed = thisTime.time + thisTime.millitm/1000.0 -
  130. (baseTime.time + baseTime.millitm/1000.0);
  131. if( elapsed == 0.0 )
  132. printf( "Frame rate = unknown\n" );
  133. else {
  134. frameRate = frameCount / elapsed;
  135. printf( "Frame rate = %5.2f fps\n", frameRate );
  136. }
  137. }
  138. }
  139. frameCount += theMesh.frames;
  140. curFrame = 0;
  141. }
  142. if ((nextFrame || !stepMode) && spinMode) {
  143. glRotatef(5.0, 0.0, 0.0, 1.0);
  144. }
  145. nextFrame = 0;
  146. for (i = 0; i < theMesh.widthX; i++) {
  147. glBegin(GL_QUAD_STRIP);
  148. lastColor = NULL;
  149. for (j = 0; j < theMesh.widthY; j++) {
  150. facet = GETFACET(curFrame, i, j);
  151. if (!smooth && lighting) {
  152. glNormal3fv(facet->normal);
  153. }
  154. if (lighting) {
  155. if (rgb) {
  156. thisColor = facet->color;
  157. glColor3fv(facet->color);
  158. } else {
  159. thisColor = facet->color;
  160. glMaterialfv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES,
  161. facet->color);
  162. }
  163. } else {
  164. if (rgb) {
  165. thisColor = facet->color;
  166. glColor3fv(facet->color);
  167. } else {
  168. thisColor = facet->color;
  169. glIndexf(facet->color[1]);
  170. }
  171. }
  172. if (!lastColor || (thisColor[0] != lastColor[0] && smooth)) {
  173. if (lastColor) {
  174. glEnd();
  175. glBegin(GL_QUAD_STRIP);
  176. }
  177. coord = GETCOORD(curFrame, i, j);
  178. if (smooth && lighting) {
  179. glNormal3fv(coord->normal);
  180. }
  181. glVertex3fv(coord->vertex);
  182. coord = GETCOORD(curFrame, i+1, j);
  183. if (smooth && lighting) {
  184. glNormal3fv(coord->normal);
  185. }
  186. glVertex3fv(coord->vertex);
  187. }
  188. coord = GETCOORD(curFrame, i, j+1);
  189. if (smooth && lighting) {
  190. glNormal3fv(coord->normal);
  191. }
  192. glVertex3fv(coord->vertex);
  193. coord = GETCOORD(curFrame, i+1, j+1);
  194. if (smooth && lighting) {
  195. glNormal3fv(coord->normal);
  196. }
  197. glVertex3fv(coord->vertex);
  198. lastColor = thisColor;
  199. }
  200. glEnd();
  201. }
  202. glFlush();
  203. if (doubleBuffer && !noSwap) {
  204. glddSwapBuffers(gw);
  205. }
  206. }
  207. static void InitMesh(void)
  208. {
  209. struct coord *coord;
  210. struct facet *facet;
  211. float dp1[3], dp2[3];
  212. float *pt1, *pt2, *pt3;
  213. float angle, d, x, y;
  214. GLint numFacets, numCoords, frameNum, i, j;
  215. theMesh.widthX = widthX;
  216. theMesh.widthY = widthY;
  217. theMesh.frames = frames;
  218. numFacets = widthX * widthY;
  219. numCoords = (widthX + 1) * (widthY + 1);
  220. theMesh.numCoords = numCoords;
  221. theMesh.numFacets = numFacets;
  222. theMesh.coords = (struct coord *)malloc(frames*numCoords*
  223. sizeof(struct coord));
  224. theMesh.facets = (struct facet *)malloc(frames*numFacets*
  225. sizeof(struct facet));
  226. if (theMesh.coords == NULL || theMesh.facets == NULL) {
  227. printf("Out of memory.\n");
  228. exit(1);
  229. }
  230. for (frameNum = 0; frameNum < frames; frameNum++) {
  231. for (i = 0; i <= widthX; i++) {
  232. x = i / (float)widthX;
  233. for (j = 0; j <= widthY; j++) {
  234. y = j / (float)widthY;
  235. d = sqrt(x*x+y*y);
  236. if (d == 0.0) {
  237. d = 0.0001;
  238. }
  239. angle = 2 * PI * d + (2 * PI / frames * frameNum);
  240. coord = GETCOORD(frameNum, i, j);
  241. coord->vertex[0] = x - 0.5;
  242. coord->vertex[1] = y - 0.5;
  243. coord->vertex[2] = (height - height * d) * cos(angle);
  244. coord->normal[0] = -(height / d) * x * ((1 - d) * 2 * PI *
  245. sin(angle) + cos(angle));
  246. coord->normal[1] = -(height / d) * y * ((1 - d) * 2 * PI *
  247. sin(angle) + cos(angle));
  248. coord->normal[2] = -1;
  249. d = 1.0 / sqrt(coord->normal[0]*coord->normal[0]+
  250. coord->normal[1]*coord->normal[1]+1);
  251. coord->normal[0] *= d;
  252. coord->normal[1] *= d;
  253. coord->normal[2] *= d;
  254. }
  255. }
  256. for (i = 0; i < widthX; i++) {
  257. for (j = 0; j < widthY; j++) {
  258. facet = GETFACET(frameNum, i, j);
  259. if (((i/checkerSize)%2)^(j/checkerSize)%2) {
  260. if (rgb) {
  261. facet->color[0] = 1.0;
  262. facet->color[1] = 0.2;
  263. facet->color[2] = 0.2;
  264. } else {
  265. facet->color[0] = colorIndexes1[0];
  266. facet->color[1] = colorIndexes1[1];
  267. facet->color[2] = colorIndexes1[2];
  268. }
  269. } else {
  270. if (rgb) {
  271. facet->color[0] = 0.2;
  272. facet->color[1] = 1.0;
  273. facet->color[2] = 0.2;
  274. } else {
  275. facet->color[0] = colorIndexes2[0];
  276. facet->color[1] = colorIndexes2[1];
  277. facet->color[2] = colorIndexes2[2];
  278. }
  279. }
  280. pt1 = GETCOORD(frameNum, i, j)->vertex;
  281. pt2 = GETCOORD(frameNum, i, j+1)->vertex;
  282. pt3 = GETCOORD(frameNum, i+1, j+1)->vertex;
  283. dp1[0] = pt2[0] - pt1[0];
  284. dp1[1] = pt2[1] - pt1[1];
  285. dp1[2] = pt2[2] - pt1[2];
  286. dp2[0] = pt3[0] - pt2[0];
  287. dp2[1] = pt3[1] - pt2[1];
  288. dp2[2] = pt3[2] - pt2[2];
  289. facet->normal[0] = dp1[1] * dp2[2] - dp1[2] * dp2[1];
  290. facet->normal[1] = dp1[2] * dp2[0] - dp1[0] * dp2[2];
  291. facet->normal[2] = dp1[0] * dp2[1] - dp1[1] * dp2[0];
  292. d = 1.0 / sqrt(facet->normal[0]*facet->normal[0]+
  293. facet->normal[1]*facet->normal[1]+
  294. facet->normal[2]*facet->normal[2]);
  295. facet->normal[0] *= d;
  296. facet->normal[1] *= d;
  297. facet->normal[2] *= d;
  298. }
  299. }
  300. }
  301. }
  302. static void InitMaterials(void)
  303. {
  304. static float ambient[] = {0.1, 0.1, 0.1, 1.0};
  305. static float diffuse[] = {0.5, 1.0, 1.0, 1.0};
  306. static float position[] = {90.0, 90.0, 150.0, 0.0};
  307. static float front_mat_shininess[] = {60.0};
  308. static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0};
  309. static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0};
  310. static float back_mat_shininess[] = {60.0};
  311. static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0};
  312. static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0};
  313. static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
  314. static float lmodel_twoside[] = {GL_TRUE};
  315. glMatrixMode(GL_PROJECTION);
  316. gluPerspective(450, 1.0, 0.5, 10.0);
  317. glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  318. glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  319. glLightfv(GL_LIGHT0, GL_POSITION, position);
  320. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  321. glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
  322. glEnable(GL_LIGHTING);
  323. glEnable(GL_LIGHT0);
  324. glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);
  325. glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular);
  326. glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse);
  327. glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess);
  328. glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular);
  329. glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse);
  330. if (rgb) {
  331. glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
  332. }
  333. if (rgb) {
  334. glEnable(GL_COLOR_MATERIAL);
  335. } else {
  336. Quit();
  337. }
  338. }
  339. static void InitTexture(void)
  340. {
  341. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  342. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  343. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  344. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  345. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  346. }
  347. static void Init(void)
  348. {
  349. glClearColor(0.0, 0.0, 0.0, 0.0);
  350. if (smooth) {
  351. glShadeModel(GL_SMOOTH);
  352. } else {
  353. glShadeModel(GL_FLAT);
  354. }
  355. glFrontFace(GL_CW);
  356. glDepthFunc(GL_LEQUAL);
  357. glEnable(GL_DEPTH_TEST);
  358. InitMaterials();
  359. InitTexture();
  360. InitMesh();
  361. glMatrixMode(GL_MODELVIEW);
  362. glTranslatef(0.0, 0.4, -1.8);
  363. glScalef(2.0, 2.0, 2.0);
  364. glRotatef(-35.0, 1.0, 0.0, 0.0);
  365. glRotatef(35.0, 0.0, 0.0, 1.0);
  366. }
  367. static GLenum Key(UINT key)
  368. {
  369. switch (key) {
  370. case VK_ESCAPE:
  371. Quit();
  372. case 'C':
  373. contouring++;
  374. if (contouring == 1) {
  375. static GLfloat map[4] = {0, 0, 20, 0};
  376. glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_LUMINANCE,
  377. GL_UNSIGNED_BYTE, (GLvoid *)contourTexture1);
  378. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
  379. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
  380. glTexGenfv(GL_S, GL_OBJECT_PLANE, map);
  381. glTexGenfv(GL_T, GL_OBJECT_PLANE, map);
  382. glEnable(GL_TEXTURE_2D);
  383. glEnable(GL_TEXTURE_GEN_S);
  384. glEnable(GL_TEXTURE_GEN_T);
  385. } else if (contouring == 2) {
  386. static GLfloat map[4] = {0, 0, 20, 0};
  387. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
  388. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
  389. glPushMatrix();
  390. glMatrixMode(GL_MODELVIEW);
  391. glLoadIdentity();
  392. glTexGenfv(GL_S, GL_EYE_PLANE, map);
  393. glTexGenfv(GL_T, GL_EYE_PLANE, map);
  394. glPopMatrix();
  395. } else {
  396. contouring = 0;
  397. glDisable(GL_TEXTURE_GEN_S);
  398. glDisable(GL_TEXTURE_GEN_T);
  399. glDisable(GL_TEXTURE_2D);
  400. }
  401. break;
  402. case 'S':
  403. smooth = !smooth;
  404. if (smooth) {
  405. glShadeModel(GL_SMOOTH);
  406. } else {
  407. glShadeModel(GL_FLAT);
  408. }
  409. break;
  410. case 'L':
  411. lighting = !lighting;
  412. if (lighting) {
  413. glEnable(GL_LIGHTING);
  414. glEnable(GL_LIGHT0);
  415. if (rgb) {
  416. glEnable(GL_COLOR_MATERIAL);
  417. }
  418. } else {
  419. glDisable(GL_LIGHTING);
  420. glDisable(GL_LIGHT0);
  421. if (rgb) {
  422. glDisable(GL_COLOR_MATERIAL);
  423. }
  424. }
  425. break;
  426. case 'D':
  427. depth = !depth;
  428. if (depth) {
  429. glEnable(GL_DEPTH_TEST);
  430. clearMask |= GL_DEPTH_BUFFER_BIT;
  431. } else {
  432. glDisable(GL_DEPTH_TEST);
  433. clearMask &= ~GL_DEPTH_BUFFER_BIT;
  434. }
  435. break;
  436. case VK_SPACE:
  437. stepMode = !stepMode;
  438. if (stepMode) {
  439. glddIdleCallback(gwMain, 0);
  440. } else {
  441. glddIdleCallback(gwMain, Animate);
  442. }
  443. break;
  444. case 'N':
  445. if (stepMode) {
  446. nextFrame = 1;
  447. }
  448. break;
  449. case 'F':
  450. displayFrameRate = !displayFrameRate;
  451. frameCount = 0;
  452. break;
  453. case 'A':
  454. spinMode = !spinMode;
  455. break;
  456. default:
  457. return GL_FALSE;
  458. }
  459. return GL_TRUE;
  460. }
  461. BOOL Message(GLDDWINDOW gw, HWND hwnd, UINT uiMsg, WPARAM wpm, LPARAM lpm,
  462. LRESULT *plr)
  463. {
  464. switch(uiMsg)
  465. {
  466. case WM_KEYDOWN:
  467. Key((UINT)wpm);
  468. break;
  469. default:
  470. return FALSE;
  471. }
  472. *plr = 0;
  473. return TRUE;
  474. }
  475. static GLenum Args(int argc, char **argv)
  476. {
  477. GLint i;
  478. rgb = GL_TRUE;
  479. doubleBuffer = GL_TRUE;
  480. directRender = GL_FALSE;
  481. videoMemory = GL_FALSE;
  482. noSwap = GL_FALSE;
  483. noClear = GL_FALSE;
  484. fullScreen = GL_FALSE;
  485. fullWidth = 640;
  486. fullHeight = 480;
  487. fullDepth = 16;
  488. useMcd = GL_FALSE;
  489. modeX = GL_FALSE;
  490. frames = 10;
  491. widthX = 10;
  492. widthY = 10;
  493. checkerSize = 2;
  494. height = 0.2;
  495. for (i = 1; i < argc; i++) {
  496. if (strcmp(argv[i], "-ci") == 0) {
  497. rgb = GL_FALSE;
  498. } else if (strcmp(argv[i], "-rgb") == 0) {
  499. rgb = GL_TRUE;
  500. } else if (strcmp(argv[i], "-sb") == 0) {
  501. doubleBuffer = GL_FALSE;
  502. } else if (strcmp(argv[i], "-db") == 0) {
  503. doubleBuffer = GL_TRUE;
  504. } else if (strcmp(argv[i], "-dr") == 0) {
  505. directRender = GL_TRUE;
  506. } else if (strcmp(argv[i], "-ir") == 0) {
  507. directRender = GL_FALSE;
  508. } else if (strcmp(argv[i], "-vm") == 0) {
  509. videoMemory = GL_TRUE;
  510. } else if (strcmp(argv[i], "-noswap") == 0) {
  511. noSwap = GL_TRUE;
  512. } else if (strcmp(argv[i], "-noclear") == 0) {
  513. noClear = GL_TRUE;
  514. } else if (strcmp(argv[i], "-full") == 0) {
  515. fullScreen = GL_TRUE;
  516. } else if (strcmp(argv[i], "-modex") == 0) {
  517. modeX = GL_TRUE;
  518. fullWidth = 320;
  519. fullHeight = 240;
  520. fullDepth = 8;
  521. } else if (strcmp(argv[i], "-mcd") == 0) {
  522. useMcd = GL_TRUE;
  523. } else if (strcmp(argv[i], "-fdim") == 0) {
  524. if (i+3 >= argc ||
  525. argv[i+1][0] == '-' ||
  526. argv[i+2][0] == '-' ||
  527. argv[i+3][0] == '-')
  528. {
  529. printf("-fdim (No numbers).\n");
  530. return GL_FALSE;
  531. }
  532. else
  533. {
  534. fullWidth = atoi(argv[++i]);
  535. fullHeight = atoi(argv[++i]);
  536. fullDepth = atoi(argv[++i]);
  537. }
  538. } else if (strcmp(argv[i], "-grid") == 0) {
  539. if (i+2 >= argc || argv[i+1][0] == '-' || argv[i+2][0] == '-') {
  540. printf("-grid (No numbers).\n");
  541. return GL_FALSE;
  542. } else {
  543. widthX = atoi(argv[++i]);
  544. widthY = atoi(argv[++i]);
  545. }
  546. } else if (strcmp(argv[i], "-size") == 0) {
  547. if (i+1 >= argc || argv[i+1][0] == '-') {
  548. printf("-checker (No number).\n");
  549. return GL_FALSE;
  550. } else {
  551. checkerSize = atoi(argv[++i]);
  552. }
  553. } else if (strcmp(argv[i], "-wave") == 0) {
  554. if (i+1 >= argc || argv[i+1][0] == '-') {
  555. printf("-wave (No number).\n");
  556. return GL_FALSE;
  557. } else {
  558. height = atof(argv[++i]);
  559. }
  560. } else if (strcmp(argv[i], "-frames") == 0) {
  561. if (i+1 >= argc || argv[i+1][0] == '-') {
  562. printf("-frames (No number).\n");
  563. return GL_FALSE;
  564. } else {
  565. frames = atoi(argv[++i]);
  566. }
  567. } else {
  568. printf("%s (Bad option).\n", argv[i]);
  569. return GL_FALSE;
  570. }
  571. }
  572. return GL_TRUE;
  573. }
  574. void __cdecl main(int argc, char **argv)
  575. {
  576. DWORD dwFlags;
  577. GLDDWINDOW gw;
  578. int iWidth, iHeight;
  579. if (Args(argc, argv) == GL_FALSE) {
  580. exit(1);
  581. }
  582. dwFlags = GLDD_Z_BUFFER_16;
  583. dwFlags |= doubleBuffer ? GLDD_BACK_BUFFER : 0;
  584. dwFlags |= videoMemory ? GLDD_VIDEO_MEMORY : 0;
  585. dwFlags |= useMcd ? GLDD_GENERIC_ACCELERATED : 0;
  586. if (fullScreen)
  587. {
  588. dwFlags |= GLDD_FULL_SCREEN;
  589. dwFlags |= modeX ? GLDD_USE_MODE_X : 0;
  590. iWidth = fullWidth;
  591. iHeight = fullHeight;
  592. }
  593. else
  594. {
  595. iWidth = 320;
  596. iHeight = 320;
  597. }
  598. gw = glddCreateWindow("Wave Demo", 10, 30, iWidth, iHeight, fullDepth,
  599. dwFlags);
  600. if (gw == NULL)
  601. {
  602. printf("glddCreateWindow failed with 0x%08lX\n", glddGetLastError());
  603. exit(1);
  604. }
  605. gwMain = gw;
  606. glddMakeCurrent(gw);
  607. Init();
  608. glddIdleCallback(gw, Animate);
  609. glddMessageCallback(gw, Message);
  610. glddRun(gw);
  611. glddDestroyWindow(gw);
  612. }