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.

1590 lines
36 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 "tk.h"
  41. #define PI 3.141592654
  42. #define BLACK 0
  43. #define GRAY 128
  44. #define WHITE 255
  45. #define BL 0x00
  46. #define WH 0xFF
  47. #define RD 0xA40000FF
  48. #define WT 0xFFFFFFFF
  49. #define CHECKIMAGEWIDTH 8
  50. #define CHECKIMAGEHEIGHT 8
  51. #define BRICKIMAGEWIDTH 16
  52. #define BRICKIMAGEHEIGHT 16
  53. GLenum rgb, doubleBuffer, directRender;
  54. float black[3] = {0.0, 0.0, 0.0};
  55. float white[3] = {1.0, 1.0, 1.0};
  56. float gray[3] = {0.5, 0.5, 0.5};
  57. float blue[3] = {0.0, 0.0, 1.0};
  58. GLint colorIndexes[3] = {0, 200, 255};
  59. GLenum polyMode;
  60. GLenum dithering;
  61. GLenum shade;
  62. GLenum doStipple;
  63. double plane[4] = {1.0, 0.0, -1.0, 0.0};
  64. float xRotation = 30.0, yRotation = 30.0;
  65. float zTranslation = -15.0;
  66. GLint singleCylinder;
  67. GLint doubleCylinder;
  68. GLint elbow, logo;
  69. GLubyte checkImage[3*CHECKIMAGEWIDTH*CHECKIMAGEHEIGHT] = {
  70. BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH,
  71. WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH,
  72. WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL,
  73. BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH,
  74. WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH,
  75. WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL,
  76. BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH,
  77. WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH,
  78. WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL,
  79. BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH,
  80. WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH,
  81. WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL,
  82. };
  83. GLuint brickImage[BRICKIMAGEWIDTH*BRICKIMAGEHEIGHT] = {
  84. RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD,
  85. RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD,
  86. RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD,
  87. RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD,
  88. WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT,
  89. RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD,
  90. RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD,
  91. RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD,
  92. RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD,
  93. WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT,
  94. RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD,
  95. RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD,
  96. RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD,
  97. RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD,
  98. WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT,
  99. RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD
  100. };
  101. GLubyte *image = checkImage;
  102. GLint imageHeight = CHECKIMAGEHEIGHT;
  103. GLint imageWidth = CHECKIMAGEWIDTH;
  104. float decal[] = {
  105. GL_DECAL,
  106. };
  107. float modulate[] = {
  108. GL_MODULATE,
  109. };
  110. float repeat[] = {
  111. GL_REPEAT,
  112. };
  113. float nearest[] = {
  114. GL_NEAREST,
  115. };
  116. GLubyte stipple[4*32] = {
  117. 0x00, 0x00, 0x00, 0x00,
  118. 0x00, 0x00, 0x00, 0x00,
  119. 0x00, 0x00, 0x00, 0x00,
  120. 0x00, 0x00, 0x00, 0x00,
  121. 0x00, 0x00, 0x00, 0x00,
  122. 0x00, 0x00, 0x00, 0x00,
  123. 0x00, 0x00, 0x00, 0x00,
  124. 0x00, 0x00, 0x00, 0x00,
  125. 0x00, 0x0F, 0xF0, 0x00,
  126. 0x00, 0x0F, 0xF0, 0x00,
  127. 0x00, 0x0F, 0xF0, 0x00,
  128. 0x00, 0x0F, 0xF0, 0x00,
  129. 0x00, 0x0F, 0xF0, 0x00,
  130. 0x00, 0x0F, 0xF0, 0x00,
  131. 0x00, 0x0F, 0xF0, 0x00,
  132. 0x00, 0x0F, 0xF0, 0x00,
  133. 0x00, 0x0F, 0xF0, 0x00,
  134. 0x00, 0x0F, 0xF0, 0x00,
  135. 0x00, 0x0F, 0xF0, 0x00,
  136. 0x00, 0x0F, 0xF0, 0x00,
  137. 0x00, 0x0F, 0xF0, 0x00,
  138. 0x00, 0x0F, 0xF0, 0x00,
  139. 0x00, 0x0F, 0xF0, 0x00,
  140. 0x00, 0x0F, 0xF0, 0x00,
  141. 0x00, 0x00, 0x00, 0x00,
  142. 0x00, 0x00, 0x00, 0x00,
  143. 0x00, 0x00, 0x00, 0x00,
  144. 0x00, 0x00, 0x00, 0x00,
  145. 0x00, 0x00, 0x00, 0x00,
  146. 0x00, 0x00, 0x00, 0x00,
  147. 0x00, 0x00, 0x00, 0x00,
  148. 0x00, 0x00, 0x00, 0x00,
  149. };
  150. float tscp[18][2] = {
  151. {
  152. 0.0, 0.0
  153. },
  154. {
  155. 1.0, 0.0
  156. },
  157. {
  158. 0.0, 0.125
  159. },
  160. {
  161. 1.0, 0.125
  162. },
  163. {
  164. 0.0, 0.250
  165. },
  166. {
  167. 1.0, 0.25
  168. },
  169. {
  170. 0.0, 0.375
  171. },
  172. {
  173. 1.0, 0.375
  174. },
  175. {
  176. 0.0, 0.50
  177. },
  178. {
  179. 1.0, 0.50
  180. },
  181. {
  182. 0.0, 0.625
  183. },
  184. {
  185. 1.0, 0.625
  186. },
  187. {
  188. 0.0, 0.75
  189. },
  190. {
  191. 1.0, 0.75
  192. },
  193. {
  194. 0.0, 0.875
  195. },
  196. {
  197. 1.0, 0.875
  198. },
  199. {
  200. 0.0, 1.0
  201. },
  202. {
  203. 1.0, 1.0
  204. }
  205. };
  206. float scp[18][3] = {
  207. {
  208. 1.000000, 0.000000, 0.000000
  209. },
  210. {
  211. 1.000000, 0.000000, 5.000000
  212. },
  213. {
  214. 0.707107, 0.707107, 0.000000
  215. },
  216. {
  217. 0.707107, 0.707107, 5.000000
  218. },
  219. {
  220. 0.000000, 1.000000, 0.000000
  221. },
  222. {
  223. 0.000000, 1.000000, 5.000000
  224. },
  225. {
  226. -0.707107, 0.707107, 0.000000
  227. },
  228. {
  229. -0.707107, 0.707107, 5.000000
  230. },
  231. {
  232. -1.000000, 0.000000, 0.000000
  233. },
  234. {
  235. -1.000000, 0.000000, 5.000000
  236. },
  237. {
  238. -0.707107, -0.707107, 0.000000
  239. },
  240. {
  241. -0.707107, -0.707107, 5.000000
  242. },
  243. {
  244. 0.000000, -1.000000, 0.000000
  245. },
  246. {
  247. 0.000000, -1.000000, 5.000000
  248. },
  249. {
  250. 0.707107, -0.707107, 0.000000
  251. },
  252. {
  253. 0.707107, -0.707107, 5.000000
  254. },
  255. {
  256. 1.000000, 0.000000, 0.000000
  257. },
  258. {
  259. 1.000000, 0.000000, 5.000000
  260. }
  261. };
  262. float dcp[18][3] = {
  263. {
  264. 1.000000, 0.000000, 0.000000
  265. },
  266. {
  267. 1.000000, 0.000000, 7.000000
  268. },
  269. {
  270. 0.707107, 0.707107, 0.000000
  271. },
  272. {
  273. 0.707107, 0.707107, 7.000000
  274. },
  275. {
  276. 0.000000, 1.000000, 0.000000
  277. },
  278. {
  279. 0.000000, 1.000000, 7.000000
  280. },
  281. {
  282. -0.707107, 0.707107, 0.000000
  283. },
  284. {
  285. -0.707107, 0.707107, 7.000000
  286. },
  287. {
  288. -1.000000, 0.000000, 0.000000
  289. },
  290. {
  291. -1.000000, 0.000000, 7.000000
  292. },
  293. {
  294. -0.707107, -0.707107, 0.000000
  295. },
  296. {
  297. -0.707107, -0.707107, 7.000000
  298. },
  299. {
  300. 0.000000, -1.000000, 0.000000
  301. },
  302. {
  303. 0.000000, -1.000000, 7.000000
  304. },
  305. {
  306. 0.707107, -0.707107, 0.000000
  307. },
  308. {
  309. 0.707107, -0.707107, 7.000000
  310. },
  311. {
  312. 1.000000, 0.000000, 0.000000
  313. },
  314. {
  315. 1.000000, 0.000000, 7.000000
  316. }
  317. };
  318. float ep[7][9][3] = {
  319. {
  320. {
  321. 1.000000, 0.000000, 0.000000
  322. },
  323. {
  324. 0.707107, 0.707107, 0.000000
  325. },
  326. {
  327. 0.000000, 1.000000, 0.000000
  328. },
  329. {
  330. -0.707107, 0.707107, 0.000000
  331. },
  332. {
  333. -1.000000, 0.000000, 0.000000
  334. },
  335. {
  336. -0.707107, -0.707107, 0.000000
  337. },
  338. {
  339. 0.000000, -1.000000, 0.000000
  340. },
  341. {
  342. 0.707107, -0.707107, 0.000000
  343. },
  344. {
  345. 1.000000, 0.000000, 0.000000
  346. }
  347. },
  348. {
  349. {
  350. 1.000000, 0.034074, 0.258819
  351. },
  352. {
  353. 0.707107, 0.717087, 0.075806
  354. },
  355. {
  356. 0.000000, 1.000000, 0.000000
  357. },
  358. {
  359. -0.707107, 0.717087, 0.075806
  360. },
  361. {
  362. -1.000000, 0.034074, 0.258819
  363. },
  364. {
  365. -0.707107, -0.648939, 0.441832
  366. },
  367. {
  368. 0.000000, -0.931852, 0.517638
  369. },
  370. {
  371. 0.707107, -0.648939, 0.441832
  372. },
  373. {
  374. 1.000000, 0.034074, 0.258819
  375. }
  376. },
  377. {
  378. {
  379. 1.000000, 0.133975, 0.500000
  380. },
  381. {
  382. 0.707107, 0.746347, 0.146447
  383. },
  384. {
  385. 0.000000, 1.000000, 0.000000
  386. },
  387. {
  388. -0.707107, 0.746347, 0.146447
  389. },
  390. {
  391. -1.000000, 0.133975, 0.500000
  392. },
  393. {
  394. -0.707107, -0.478398, 0.853553
  395. },
  396. {
  397. 0.000000, -0.732051, 1.000000
  398. },
  399. {
  400. 0.707107, -0.478398, 0.853553
  401. },
  402. {
  403. 1.000000, 0.133975, 0.500000
  404. }
  405. },
  406. {
  407. {
  408. 1.000000, 0.292893, 0.707107
  409. },
  410. {
  411. 0.707107, 0.792893, 0.207107
  412. },
  413. {
  414. 0.000000, 1.000000, 0.000000
  415. },
  416. {
  417. -0.707107, 0.792893, 0.207107
  418. },
  419. {
  420. -1.000000, 0.292893, 0.707107
  421. },
  422. {
  423. -0.707107, -0.207107, 1.207107
  424. },
  425. {
  426. 0.000000, -0.414214, 1.414214
  427. },
  428. {
  429. 0.707107, -0.207107, 1.207107
  430. },
  431. {
  432. 1.000000, 0.292893, 0.707107
  433. }
  434. },
  435. {
  436. {
  437. 1.000000, 0.500000, 0.866025
  438. },
  439. {
  440. 0.707107, 0.853553, 0.253653
  441. },
  442. {
  443. 0.000000, 1.000000, 0.000000
  444. },
  445. {
  446. -0.707107, 0.853553, 0.253653
  447. },
  448. {
  449. -1.000000, 0.500000, 0.866025
  450. },
  451. {
  452. -0.707107, 0.146447, 1.478398
  453. },
  454. {
  455. 0.000000, 0.000000, 1.732051
  456. },
  457. {
  458. 0.707107, 0.146447, 1.478398
  459. },
  460. {
  461. 1.000000, 0.500000, 0.866025
  462. }
  463. },
  464. {
  465. {
  466. 1.000000, 0.741181, 0.965926
  467. },
  468. {
  469. 0.707107, 0.924194, 0.282913
  470. },
  471. {
  472. 0.000000, 1.000000, 0.000000
  473. },
  474. {
  475. -0.707107, 0.924194, 0.282913
  476. },
  477. {
  478. -1.000000, 0.741181, 0.965926
  479. },
  480. {
  481. -0.707107, 0.558168, 1.648939
  482. },
  483. {
  484. 0.000000, 0.482362, 1.931852
  485. },
  486. {
  487. 0.707107, 0.558168, 1.648939
  488. },
  489. {
  490. 1.000000, 0.741181, 0.965926
  491. }
  492. },
  493. {
  494. {
  495. 1.000000, 1.000000, 1.000000
  496. },
  497. {
  498. 0.707107, 1.000000, 0.292893
  499. },
  500. {
  501. 0.000000, 1.000000, 0.000000
  502. },
  503. {
  504. -0.707107, 1.000000, 0.292893
  505. },
  506. {
  507. -1.000000, 1.000000, 1.000000
  508. },
  509. {
  510. -0.707107, 1.000000, 1.707107
  511. },
  512. {
  513. 0.000000, 1.000000, 2.000000
  514. },
  515. {
  516. 0.707107, 1.000000, 1.707107
  517. },
  518. {
  519. 1.000000, 1.000000, 1.000000
  520. }
  521. }
  522. };
  523. float en[7][9][3] = {
  524. {
  525. {
  526. 1.000000, 0.000000, 0.000000
  527. },
  528. {
  529. 0.707107, 0.707107, 0.000000
  530. },
  531. {
  532. 0.000000, 1.000000, 0.000000
  533. },
  534. {
  535. -0.707107, 0.707107, 0.000000
  536. },
  537. {
  538. -1.000000, 0.000000, 0.000000
  539. },
  540. {
  541. -0.707107, -0.707107, 0.000000
  542. },
  543. {
  544. 0.000000, -1.000000, 0.000000
  545. },
  546. {
  547. 0.707107, -0.707107, 0.000000
  548. },
  549. {
  550. 1.000000, 0.000000, 0.000000
  551. }
  552. },
  553. {
  554. {
  555. 1.000000, 0.000000, 0.000000
  556. },
  557. {
  558. 0.707107, 0.683013, -0.183013
  559. },
  560. {
  561. 0.000000, 0.965926, -0.258819
  562. },
  563. {
  564. -0.707107, 0.683013, -0.183013
  565. },
  566. {
  567. -1.000000, 0.000000, 0.000000
  568. },
  569. {
  570. -0.707107, -0.683013, 0.183013
  571. },
  572. {
  573. 0.000000, -0.965926, 0.258819
  574. },
  575. {
  576. 0.707107, -0.683013, 0.183013
  577. },
  578. {
  579. 1.000000, 0.000000, 0.000000
  580. }
  581. },
  582. {
  583. {
  584. 1.000000, 0.000000, 0.000000
  585. },
  586. {
  587. 0.707107, 0.612372, -0.353553
  588. },
  589. {
  590. 0.000000, 0.866025, -0.500000
  591. },
  592. {
  593. -0.707107, 0.612372, -0.353553
  594. },
  595. {
  596. -1.000000, 0.000000, 0.000000
  597. },
  598. {
  599. -0.707107, -0.612372, 0.353553
  600. },
  601. {
  602. 0.000000, -0.866025, 0.500000
  603. },
  604. {
  605. 0.707107, -0.612372, 0.353553
  606. },
  607. {
  608. 1.000000, 0.000000, 0.000000
  609. }
  610. },
  611. {
  612. {
  613. 1.000000, 0.000000, 0.000000
  614. },
  615. {
  616. 0.707107, 0.500000, -0.500000
  617. },
  618. {
  619. 0.000000, 0.707107, -0.707107
  620. },
  621. {
  622. -0.707107, 0.500000, -0.500000
  623. },
  624. {
  625. -1.000000, 0.000000, 0.000000
  626. },
  627. {
  628. -0.707107, -0.500000, 0.500000
  629. },
  630. {
  631. 0.000000, -0.707107, 0.707107
  632. },
  633. {
  634. 0.707107, -0.500000, 0.500000
  635. },
  636. {
  637. 1.000000, 0.000000, 0.000000
  638. }
  639. },
  640. {
  641. {
  642. 1.000000, 0.000000, 0.000000
  643. },
  644. {
  645. 0.707107, 0.353553, -0.612372
  646. },
  647. {
  648. 0.000000, 0.500000, -0.866025
  649. },
  650. {
  651. -0.707107, 0.353553, -0.612372
  652. },
  653. {
  654. -1.000000, 0.000000, 0.000000
  655. },
  656. {
  657. -0.707107, -0.353553, 0.612372
  658. },
  659. {
  660. 0.000000, -0.500000, 0.866025
  661. },
  662. {
  663. 0.707107, -0.353553, 0.612372
  664. },
  665. {
  666. 1.000000, 0.000000, 0.000000
  667. }
  668. },
  669. {
  670. {
  671. 1.000000, 0.000000, 0.000000
  672. },
  673. {
  674. 0.707107, 0.183013, -0.683013
  675. },
  676. {
  677. 0.000000, 0.258819, -0.965926
  678. },
  679. {
  680. -0.707107, 0.183013, -0.683013
  681. },
  682. {
  683. -1.000000, 0.000000, 0.000000
  684. },
  685. {
  686. -0.707107, -0.183013, 0.683013
  687. },
  688. {
  689. 0.000000, -0.258819, 0.965926
  690. },
  691. {
  692. 0.707107, -0.183013, 0.683013
  693. },
  694. {
  695. 1.000000, 0.000000, 0.000000
  696. }
  697. },
  698. {
  699. {
  700. 1.000000, 0.000000, 0.000000
  701. },
  702. {
  703. 0.707107, 0.000000, -0.707107
  704. },
  705. {
  706. 0.000000, 0.000000, -1.000000
  707. },
  708. {
  709. -0.707107, 0.000000, -0.707107
  710. },
  711. {
  712. -1.000000, 0.000000, 0.000000
  713. },
  714. {
  715. -0.707107, 0.000000, 0.707107
  716. },
  717. {
  718. 0.000000, 0.000000, 1.000000
  719. },
  720. {
  721. 0.707107, 0.000000, 0.707107
  722. },
  723. {
  724. 1.000000, 0.000000, 0.000000
  725. }
  726. }
  727. };
  728. float tep[7][9][2] = {
  729. {
  730. {
  731. 0, 0.0
  732. },
  733. {
  734. 0.125, 0.0
  735. },
  736. {
  737. 0.25, 0.0
  738. },
  739. {
  740. 0.375, 0.0
  741. },
  742. {
  743. 0.5, 0.0
  744. },
  745. {
  746. 0.625, 0.0
  747. },
  748. {
  749. 0.75, 0.0
  750. },
  751. {
  752. 0.875, 0.0
  753. },
  754. {
  755. 1.0, 0.0
  756. }
  757. },
  758. {
  759. {
  760. 0, 0.16667
  761. },
  762. {
  763. 0.125, 0.16667
  764. },
  765. {
  766. 0.25, 0.16667
  767. },
  768. {
  769. 0.375, 0.16667
  770. },
  771. {
  772. 0.5, 0.16667
  773. },
  774. {
  775. 0.625, 0.16667
  776. },
  777. {
  778. 0.75, 0.16667
  779. },
  780. {
  781. 0.875, 0.16667
  782. },
  783. {
  784. 1.0, 0.16667
  785. }
  786. },
  787. {
  788. {
  789. 0, 0.33333
  790. },
  791. {
  792. 0.125, 0.33333
  793. },
  794. {
  795. 0.25, 0.33333
  796. },
  797. {
  798. 0.375, 0.33333
  799. },
  800. {
  801. 0.5, 0.33333
  802. },
  803. {
  804. 0.625, 0.33333
  805. },
  806. {
  807. 0.75, 0.33333
  808. },
  809. {
  810. 0.875, 0.33333
  811. },
  812. {
  813. 1.0, 0.33333
  814. }
  815. },
  816. {
  817. {
  818. 0, 0.5
  819. },
  820. {
  821. 0.125, 0.5
  822. },
  823. {
  824. 0.25, 0.5
  825. },
  826. {
  827. 0.375, 0.5
  828. },
  829. {
  830. 0.5, 0.5
  831. },
  832. {
  833. 0.625, 0.5
  834. },
  835. {
  836. 0.75, 0.5
  837. },
  838. {
  839. 0.875, 0.5
  840. },
  841. {
  842. 1.0, 0.5
  843. }
  844. },
  845. {
  846. {
  847. 0, 0.6667
  848. },
  849. {
  850. 0.125, 0.6667
  851. },
  852. {
  853. 0.25, 0.6667
  854. },
  855. {
  856. 0.375, 0.6667
  857. },
  858. {
  859. 0.5, 0.6667
  860. },
  861. {
  862. 0.625, 0.6667
  863. },
  864. {
  865. 0.75, 0.6667
  866. },
  867. {
  868. 0.875, 0.6667
  869. },
  870. {
  871. 1.0, 0.6667
  872. }
  873. },
  874. {
  875. {
  876. 0, 0.83333
  877. },
  878. {
  879. 0.125, 0.83333
  880. },
  881. {
  882. 0.25, 0.83333
  883. },
  884. {
  885. 0.375, 0.83333
  886. },
  887. {
  888. 0.5, 0.83333
  889. },
  890. {
  891. 0.625, 0.83333
  892. },
  893. {
  894. 0.75, 0.83333
  895. },
  896. {
  897. 0.875, 0.83333
  898. },
  899. {
  900. 1.0, 0.83333
  901. }
  902. },
  903. {
  904. {
  905. 0, 1.0
  906. },
  907. {
  908. 0.125, 1.0
  909. },
  910. {
  911. 0.25, 1.0
  912. },
  913. {
  914. 0.375, 1.0
  915. },
  916. {
  917. 0.5, 1.0
  918. },
  919. {
  920. 0.625, 1.0
  921. },
  922. {
  923. 0.75, 1.0
  924. },
  925. {
  926. 0.875, 1.0
  927. },
  928. {
  929. 1.0, 1.0
  930. }
  931. }
  932. };
  933. static void SetUpAntiAliasedGrayScale(void)
  934. {
  935. float color;
  936. GLint i, j;
  937. for (i = 0; i < 16; i++) {
  938. color = (2 * i + 1) / 32.0;
  939. for (j = 0; j < 16; j++) {
  940. tkSetOneColor(i*16+j, color*j/15.0, color*j/15.0, color*j/15.0);
  941. }
  942. }
  943. }
  944. static void BendForward(void)
  945. {
  946. glTranslatef(0.0, 1.0, 0.0);
  947. glRotatef(90.0, 1, 0, 0);
  948. glTranslatef(0.0, -1.0, 0.0);
  949. }
  950. static void BendLeft(void)
  951. {
  952. glRotatef(-90.0, 0, 0, 1);
  953. glTranslatef(0.0, 1.0, 0.0);
  954. glRotatef(90.0, 1, 0, 0);
  955. glTranslatef(0.0, -1.0, 0.0);
  956. }
  957. static void BendRight(void)
  958. {
  959. glRotatef(90.0, 0, 0, 1);
  960. glTranslatef(0.0, 1.0, 0.0);
  961. glRotatef(90.0, 1, 0, 0);
  962. glTranslatef(0.0, -1.0, 0.0);
  963. }
  964. static void BuildSingleCylinder(void)
  965. {
  966. glNewList(singleCylinder, GL_COMPILE);
  967. glBegin(GL_TRIANGLE_STRIP);
  968. glNormal3fv(scp[0]); glTexCoord2fv(tscp[0]); glVertex3fv(scp[0]);
  969. glNormal3fv(scp[0]); glTexCoord2fv(tscp[1]); glVertex3fv(scp[1]);
  970. glNormal3fv(scp[2]); glTexCoord2fv(tscp[2]); glVertex3fv(scp[2]);
  971. glNormal3fv(scp[2]); glTexCoord2fv(tscp[3]); glVertex3fv(scp[3]);
  972. glNormal3fv(scp[4]); glTexCoord2fv(tscp[4]); glVertex3fv(scp[4]);
  973. glNormal3fv(scp[4]); glTexCoord2fv(tscp[5]); glVertex3fv(scp[5]);
  974. glNormal3fv(scp[6]); glTexCoord2fv(tscp[6]); glVertex3fv(scp[6]);
  975. glNormal3fv(scp[6]); glTexCoord2fv(tscp[7]); glVertex3fv(scp[7]);
  976. glNormal3fv(scp[8]); glTexCoord2fv(tscp[8]); glVertex3fv(scp[8]);
  977. glNormal3fv(scp[8]); glTexCoord2fv(tscp[9]); glVertex3fv(scp[9]);
  978. glNormal3fv(scp[10]); glTexCoord2fv(tscp[10]); glVertex3fv(scp[10]);
  979. glNormal3fv(scp[10]); glTexCoord2fv(tscp[11]); glVertex3fv(scp[11]);
  980. glNormal3fv(scp[12]); glTexCoord2fv(tscp[12]); glVertex3fv(scp[12]);
  981. glNormal3fv(scp[12]); glTexCoord2fv(tscp[13]); glVertex3fv(scp[13]);
  982. glNormal3fv(scp[14]); glTexCoord2fv(tscp[14]); glVertex3fv(scp[14]);
  983. glNormal3fv(scp[14]); glTexCoord2fv(tscp[15]); glVertex3fv(scp[15]);
  984. glNormal3fv(scp[16]); glTexCoord2fv(tscp[16]); glVertex3fv(scp[16]);
  985. glNormal3fv(scp[16]); glTexCoord2fv(tscp[17]); glVertex3fv(scp[17]);
  986. glEnd();
  987. glEndList();
  988. }
  989. static void BuildDoubleCylinder(void)
  990. {
  991. glNewList(doubleCylinder, GL_COMPILE);
  992. glBegin(GL_TRIANGLE_STRIP);
  993. glNormal3fv(dcp[0]); glTexCoord2fv(tscp[0]); glVertex3fv(dcp[0]);
  994. glNormal3fv(dcp[0]); glTexCoord2fv(tscp[1]); glVertex3fv(dcp[1]);
  995. glNormal3fv(dcp[2]); glTexCoord2fv(tscp[2]); glVertex3fv(dcp[2]);
  996. glNormal3fv(dcp[2]); glTexCoord2fv(tscp[3]); glVertex3fv(dcp[3]);
  997. glNormal3fv(dcp[4]); glTexCoord2fv(tscp[4]); glVertex3fv(dcp[4]);
  998. glNormal3fv(dcp[4]); glTexCoord2fv(tscp[5]); glVertex3fv(dcp[5]);
  999. glNormal3fv(dcp[6]); glTexCoord2fv(tscp[6]); glVertex3fv(dcp[6]);
  1000. glNormal3fv(dcp[6]); glTexCoord2fv(tscp[7]); glVertex3fv(dcp[7]);
  1001. glNormal3fv(dcp[8]); glTexCoord2fv(tscp[8]); glVertex3fv(dcp[8]);
  1002. glNormal3fv(dcp[8]); glTexCoord2fv(tscp[9]); glVertex3fv(dcp[9]);
  1003. glNormal3fv(dcp[10]); glTexCoord2fv(tscp[10]); glVertex3fv(dcp[10]);
  1004. glNormal3fv(dcp[10]); glTexCoord2fv(tscp[11]); glVertex3fv(dcp[11]);
  1005. glNormal3fv(dcp[12]); glTexCoord2fv(tscp[12]); glVertex3fv(dcp[12]);
  1006. glNormal3fv(dcp[12]); glTexCoord2fv(tscp[13]); glVertex3fv(dcp[13]);
  1007. glNormal3fv(dcp[14]); glTexCoord2fv(tscp[14]); glVertex3fv(dcp[14]);
  1008. glNormal3fv(dcp[14]); glTexCoord2fv(tscp[15]); glVertex3fv(dcp[15]);
  1009. glNormal3fv(dcp[16]); glTexCoord2fv(tscp[16]); glVertex3fv(dcp[16]);
  1010. glNormal3fv(dcp[16]); glTexCoord2fv(tscp[17]); glVertex3fv(dcp[17]);
  1011. glEnd();
  1012. glEndList();
  1013. }
  1014. static void BuildElbow(void)
  1015. {
  1016. glNewList(elbow, GL_COMPILE);
  1017. glBegin(GL_TRIANGLE_STRIP);
  1018. glNormal3fv(en[0][0]); glTexCoord2fv(tep[0][0]); glVertex3fv(ep[0][0]);
  1019. glNormal3fv(en[1][0]); glTexCoord2fv(tep[1][0]); glVertex3fv(ep[1][0]);
  1020. glNormal3fv(en[0][1]); glTexCoord2fv(tep[0][1]); glVertex3fv(ep[0][1]);
  1021. glNormal3fv(en[1][1]); glTexCoord2fv(tep[1][1]); glVertex3fv(ep[1][1]);
  1022. glNormal3fv(en[0][2]); glTexCoord2fv(tep[0][2]); glVertex3fv(ep[0][2]);
  1023. glNormal3fv(en[1][2]); glTexCoord2fv(tep[1][2]); glVertex3fv(ep[1][2]);
  1024. glNormal3fv(en[0][3]); glTexCoord2fv(tep[0][3]); glVertex3fv(ep[0][3]);
  1025. glNormal3fv(en[1][3]); glTexCoord2fv(tep[1][3]); glVertex3fv(ep[1][3]);
  1026. glNormal3fv(en[0][4]); glTexCoord2fv(tep[0][4]); glVertex3fv(ep[0][4]);
  1027. glNormal3fv(en[1][4]); glTexCoord2fv(tep[1][4]); glVertex3fv(ep[1][4]);
  1028. glNormal3fv(en[0][5]); glTexCoord2fv(tep[0][5]); glVertex3fv(ep[0][5]);
  1029. glNormal3fv(en[1][5]); glTexCoord2fv(tep[1][5]); glVertex3fv(ep[1][5]);
  1030. glNormal3fv(en[0][6]); glTexCoord2fv(tep[0][6]); glVertex3fv(ep[0][6]);
  1031. glNormal3fv(en[1][6]); glTexCoord2fv(tep[1][6]); glVertex3fv(ep[1][6]);
  1032. glNormal3fv(en[0][7]); glTexCoord2fv(tep[0][7]); glVertex3fv(ep[0][7]);
  1033. glNormal3fv(en[1][7]); glTexCoord2fv(tep[1][7]); glVertex3fv(ep[1][7]);
  1034. glNormal3fv(en[0][8]); glTexCoord2fv(tep[0][8]); glVertex3fv(ep[0][8]);
  1035. glNormal3fv(en[1][8]); glTexCoord2fv(tep[1][8]); glVertex3fv(ep[1][8]);
  1036. glEnd();
  1037. glBegin(GL_TRIANGLE_STRIP);
  1038. glNormal3fv(en[1][0]); glTexCoord2fv(tep[1][0]); glVertex3fv(ep[1][0]);
  1039. glNormal3fv(en[2][0]); glTexCoord2fv(tep[2][0]); glVertex3fv(ep[2][0]);
  1040. glNormal3fv(en[1][1]); glTexCoord2fv(tep[1][1]); glVertex3fv(ep[1][1]);
  1041. glNormal3fv(en[2][1]); glTexCoord2fv(tep[2][1]); glVertex3fv(ep[2][1]);
  1042. glNormal3fv(en[1][2]); glTexCoord2fv(tep[1][2]); glVertex3fv(ep[1][2]);
  1043. glNormal3fv(en[2][2]); glTexCoord2fv(tep[2][2]); glVertex3fv(ep[2][2]);
  1044. glNormal3fv(en[1][3]); glTexCoord2fv(tep[1][3]); glVertex3fv(ep[1][3]);
  1045. glNormal3fv(en[2][3]); glTexCoord2fv(tep[2][3]); glVertex3fv(ep[2][3]);
  1046. glNormal3fv(en[1][4]); glTexCoord2fv(tep[1][4]); glVertex3fv(ep[1][4]);
  1047. glNormal3fv(en[2][4]); glTexCoord2fv(tep[2][4]); glVertex3fv(ep[2][4]);
  1048. glNormal3fv(en[1][5]); glTexCoord2fv(tep[1][5]); glVertex3fv(ep[1][5]);
  1049. glNormal3fv(en[2][5]); glTexCoord2fv(tep[2][5]); glVertex3fv(ep[2][5]);
  1050. glNormal3fv(en[1][6]); glTexCoord2fv(tep[1][6]); glVertex3fv(ep[1][6]);
  1051. glNormal3fv(en[2][6]); glTexCoord2fv(tep[2][6]); glVertex3fv(ep[2][6]);
  1052. glNormal3fv(en[1][7]); glTexCoord2fv(tep[1][7]); glVertex3fv(ep[1][7]);
  1053. glNormal3fv(en[2][7]); glTexCoord2fv(tep[2][7]); glVertex3fv(ep[2][7]);
  1054. glNormal3fv(en[1][8]); glTexCoord2fv(tep[1][8]); glVertex3fv(ep[1][8]);
  1055. glNormal3fv(en[2][8]); glTexCoord2fv(tep[2][8]); glVertex3fv(ep[2][8]);
  1056. glEnd();
  1057. glBegin(GL_TRIANGLE_STRIP);
  1058. glNormal3fv(en[2][0]); glTexCoord2fv(tep[2][0]); glVertex3fv(ep[2][0]);
  1059. glNormal3fv(en[3][0]); glTexCoord2fv(tep[3][0]); glVertex3fv(ep[3][0]);
  1060. glNormal3fv(en[2][1]); glTexCoord2fv(tep[2][1]); glVertex3fv(ep[2][1]);
  1061. glNormal3fv(en[3][1]); glTexCoord2fv(tep[3][1]); glVertex3fv(ep[3][1]);
  1062. glNormal3fv(en[2][2]); glTexCoord2fv(tep[2][2]); glVertex3fv(ep[2][2]);
  1063. glNormal3fv(en[3][2]); glTexCoord2fv(tep[3][2]); glVertex3fv(ep[3][2]);
  1064. glNormal3fv(en[2][3]); glTexCoord2fv(tep[2][3]); glVertex3fv(ep[2][3]);
  1065. glNormal3fv(en[3][3]); glTexCoord2fv(tep[3][3]); glVertex3fv(ep[3][3]);
  1066. glNormal3fv(en[2][4]); glTexCoord2fv(tep[2][4]); glVertex3fv(ep[2][4]);
  1067. glNormal3fv(en[3][4]); glTexCoord2fv(tep[3][4]); glVertex3fv(ep[3][4]);
  1068. glNormal3fv(en[2][5]); glTexCoord2fv(tep[2][5]); glVertex3fv(ep[2][5]);
  1069. glNormal3fv(en[3][5]); glTexCoord2fv(tep[3][5]); glVertex3fv(ep[3][5]);
  1070. glNormal3fv(en[2][6]); glTexCoord2fv(tep[2][6]); glVertex3fv(ep[2][6]);
  1071. glNormal3fv(en[3][6]); glTexCoord2fv(tep[3][6]); glVertex3fv(ep[3][6]);
  1072. glNormal3fv(en[2][7]); glTexCoord2fv(tep[2][7]); glVertex3fv(ep[2][7]);
  1073. glNormal3fv(en[3][7]); glTexCoord2fv(tep[3][7]); glVertex3fv(ep[3][7]);
  1074. glNormal3fv(en[2][8]); glTexCoord2fv(tep[2][8]); glVertex3fv(ep[2][8]);
  1075. glNormal3fv(en[3][8]); glTexCoord2fv(tep[3][8]); glVertex3fv(ep[3][8]);
  1076. glEnd();
  1077. glBegin(GL_TRIANGLE_STRIP);
  1078. glNormal3fv(en[3][0]); glTexCoord2fv(tep[3][0]); glVertex3fv(ep[3][0]);
  1079. glNormal3fv(en[4][0]); glTexCoord2fv(tep[4][0]); glVertex3fv(ep[4][0]);
  1080. glNormal3fv(en[3][1]); glTexCoord2fv(tep[3][1]); glVertex3fv(ep[3][1]);
  1081. glNormal3fv(en[4][1]); glTexCoord2fv(tep[4][1]); glVertex3fv(ep[4][1]);
  1082. glNormal3fv(en[3][2]); glTexCoord2fv(tep[3][2]); glVertex3fv(ep[3][2]);
  1083. glNormal3fv(en[4][2]); glTexCoord2fv(tep[4][2]); glVertex3fv(ep[4][2]);
  1084. glNormal3fv(en[3][3]); glTexCoord2fv(tep[3][3]); glVertex3fv(ep[3][3]);
  1085. glNormal3fv(en[4][3]); glTexCoord2fv(tep[4][3]); glVertex3fv(ep[4][3]);
  1086. glNormal3fv(en[3][4]); glTexCoord2fv(tep[3][4]); glVertex3fv(ep[3][4]);
  1087. glNormal3fv(en[4][4]); glTexCoord2fv(tep[4][4]); glVertex3fv(ep[4][4]);
  1088. glNormal3fv(en[3][5]); glTexCoord2fv(tep[3][5]); glVertex3fv(ep[3][5]);
  1089. glNormal3fv(en[4][5]); glTexCoord2fv(tep[4][5]); glVertex3fv(ep[4][5]);
  1090. glNormal3fv(en[3][6]); glTexCoord2fv(tep[3][6]); glVertex3fv(ep[3][6]);
  1091. glNormal3fv(en[4][6]); glTexCoord2fv(tep[4][6]); glVertex3fv(ep[4][6]);
  1092. glNormal3fv(en[3][7]); glTexCoord2fv(tep[3][7]); glVertex3fv(ep[3][7]);
  1093. glNormal3fv(en[4][7]); glTexCoord2fv(tep[4][7]); glVertex3fv(ep[4][7]);
  1094. glNormal3fv(en[3][8]); glTexCoord2fv(tep[3][8]); glVertex3fv(ep[3][8]);
  1095. glNormal3fv(en[4][8]); glTexCoord2fv(tep[4][8]); glVertex3fv(ep[4][8]);
  1096. glEnd();
  1097. glBegin(GL_TRIANGLE_STRIP);
  1098. glNormal3fv(en[4][0]); glTexCoord2fv(tep[4][0]); glVertex3fv(ep[4][0]);
  1099. glNormal3fv(en[5][0]); glTexCoord2fv(tep[5][0]); glVertex3fv(ep[5][0]);
  1100. glNormal3fv(en[4][1]); glTexCoord2fv(tep[4][1]); glVertex3fv(ep[4][1]);
  1101. glNormal3fv(en[5][1]); glTexCoord2fv(tep[5][1]); glVertex3fv(ep[5][1]);
  1102. glNormal3fv(en[4][2]); glTexCoord2fv(tep[4][2]); glVertex3fv(ep[4][2]);
  1103. glNormal3fv(en[5][2]); glTexCoord2fv(tep[5][2]); glVertex3fv(ep[5][2]);
  1104. glNormal3fv(en[4][3]); glTexCoord2fv(tep[4][3]); glVertex3fv(ep[4][3]);
  1105. glNormal3fv(en[5][3]); glTexCoord2fv(tep[5][3]); glVertex3fv(ep[5][3]);
  1106. glNormal3fv(en[4][4]); glTexCoord2fv(tep[4][4]); glVertex3fv(ep[4][4]);
  1107. glNormal3fv(en[5][4]); glTexCoord2fv(tep[5][4]); glVertex3fv(ep[5][4]);
  1108. glNormal3fv(en[4][5]); glTexCoord2fv(tep[4][5]); glVertex3fv(ep[4][5]);
  1109. glNormal3fv(en[5][5]); glTexCoord2fv(tep[5][5]); glVertex3fv(ep[5][5]);
  1110. glNormal3fv(en[4][6]); glTexCoord2fv(tep[4][6]); glVertex3fv(ep[4][6]);
  1111. glNormal3fv(en[5][6]); glTexCoord2fv(tep[5][6]); glVertex3fv(ep[5][6]);
  1112. glNormal3fv(en[4][7]); glTexCoord2fv(tep[4][7]); glVertex3fv(ep[4][7]);
  1113. glNormal3fv(en[5][7]); glTexCoord2fv(tep[5][7]); glVertex3fv(ep[5][7]);
  1114. glNormal3fv(en[4][8]); glTexCoord2fv(tep[4][8]); glVertex3fv(ep[4][8]);
  1115. glNormal3fv(en[5][8]); glTexCoord2fv(tep[5][8]); glVertex3fv(ep[5][8]);
  1116. glEnd();
  1117. glBegin(GL_TRIANGLE_STRIP);
  1118. glNormal3fv(en[5][0]); glTexCoord2fv(tep[5][0]); glVertex3fv(ep[5][0]);
  1119. glNormal3fv(en[6][0]); glTexCoord2fv(tep[6][0]); glVertex3fv(ep[6][0]);
  1120. glNormal3fv(en[5][1]); glTexCoord2fv(tep[5][1]); glVertex3fv(ep[5][1]);
  1121. glNormal3fv(en[6][1]); glTexCoord2fv(tep[6][1]); glVertex3fv(ep[6][1]);
  1122. glNormal3fv(en[5][2]); glTexCoord2fv(tep[5][2]); glVertex3fv(ep[5][2]);
  1123. glNormal3fv(en[6][2]); glTexCoord2fv(tep[6][2]); glVertex3fv(ep[6][2]);
  1124. glNormal3fv(en[5][3]); glTexCoord2fv(tep[5][3]); glVertex3fv(ep[5][3]);
  1125. glNormal3fv(en[6][3]); glTexCoord2fv(tep[6][3]); glVertex3fv(ep[6][3]);
  1126. glNormal3fv(en[5][4]); glTexCoord2fv(tep[5][4]); glVertex3fv(ep[5][4]);
  1127. glNormal3fv(en[6][4]); glTexCoord2fv(tep[6][4]); glVertex3fv(ep[6][4]);
  1128. glNormal3fv(en[5][5]); glTexCoord2fv(tep[5][5]); glVertex3fv(ep[5][5]);
  1129. glNormal3fv(en[6][5]); glTexCoord2fv(tep[6][5]); glVertex3fv(ep[6][5]);
  1130. glNormal3fv(en[5][6]); glTexCoord2fv(tep[5][6]); glVertex3fv(ep[5][6]);
  1131. glNormal3fv(en[6][6]); glTexCoord2fv(tep[6][6]); glVertex3fv(ep[6][6]);
  1132. glNormal3fv(en[5][7]); glTexCoord2fv(tep[5][7]); glVertex3fv(ep[5][7]);
  1133. glNormal3fv(en[6][7]); glTexCoord2fv(tep[6][7]); glVertex3fv(ep[6][7]);
  1134. glNormal3fv(en[5][8]); glTexCoord2fv(tep[5][8]); glVertex3fv(ep[5][8]);
  1135. glNormal3fv(en[6][8]); glTexCoord2fv(tep[6][8]); glVertex3fv(ep[6][8]);
  1136. glEnd();
  1137. glEndList();
  1138. }
  1139. static void BuildLogo(void)
  1140. {
  1141. glNewList(logo, GL_COMPILE);
  1142. glTranslatef(5.5, -3.5, 4.5);
  1143. glTranslatef(0.0, 0.0, -7.0);
  1144. glCallList(doubleCylinder);
  1145. BendForward();
  1146. glCallList(elbow);
  1147. glTranslatef(0.0, 0.0, -7.0);
  1148. glCallList(doubleCylinder);
  1149. BendForward();
  1150. glCallList(elbow);
  1151. glTranslatef(0.0, 0.0, -5.0);
  1152. glCallList(singleCylinder);
  1153. BendRight();
  1154. glCallList(elbow);
  1155. glTranslatef(0.0, 0.0, -7.0);
  1156. glCallList(doubleCylinder);
  1157. BendForward();
  1158. glCallList(elbow);
  1159. glTranslatef(0.0, 0.0, -7.0);
  1160. glCallList(doubleCylinder);
  1161. BendForward();
  1162. glCallList(elbow);
  1163. glTranslatef(0.0, 0.0, -5.0);
  1164. glCallList(singleCylinder);
  1165. BendLeft();
  1166. glCallList(elbow);
  1167. glTranslatef(0.0, 0.0, -7.0);
  1168. glCallList(doubleCylinder);
  1169. BendForward();
  1170. glCallList(elbow);
  1171. glTranslatef(0.0, 0.0, -7.0);
  1172. glCallList(doubleCylinder);
  1173. BendForward();
  1174. glCallList(elbow);
  1175. glTranslatef(0.0, 0.0, -5.0);
  1176. glCallList(singleCylinder);
  1177. BendRight();
  1178. glCallList(elbow);
  1179. glTranslatef(0.0, 0.0, -7.0);
  1180. glCallList(doubleCylinder);
  1181. BendForward();
  1182. glCallList(elbow);
  1183. glTranslatef(0.0, 0.0, -7.0);
  1184. glCallList(doubleCylinder);
  1185. BendForward();
  1186. glCallList(elbow);
  1187. glTranslatef(0.0, 0.0, -5.0);
  1188. glCallList(singleCylinder);
  1189. BendLeft();
  1190. glCallList(elbow);
  1191. glTranslatef(0.0, 0.0, -7.0);
  1192. glCallList(doubleCylinder);
  1193. BendForward();
  1194. glCallList(elbow);
  1195. glTranslatef(0.0, 0.0, -7.0);
  1196. glCallList(doubleCylinder);
  1197. BendForward();
  1198. glCallList(elbow);
  1199. glTranslatef(0.0, 0.0, -5.0);
  1200. glCallList(singleCylinder);
  1201. BendRight();
  1202. glCallList(elbow);
  1203. glTranslatef(0.0, 0.0, -7.0);
  1204. glCallList(doubleCylinder);
  1205. BendForward();
  1206. glCallList(elbow);
  1207. glTranslatef(0.0, 0.0, -7.0);
  1208. glCallList(doubleCylinder);
  1209. BendForward();
  1210. glCallList(elbow);
  1211. glTranslatef(0.0, 0.0, -5.0);
  1212. glCallList(singleCylinder);
  1213. BendLeft();
  1214. glCallList(elbow);
  1215. glEndList();
  1216. }
  1217. static void BuildLists(void)
  1218. {
  1219. singleCylinder = glGenLists(1);
  1220. doubleCylinder = glGenLists(1);
  1221. elbow = glGenLists(1);
  1222. logo = glGenLists(1);
  1223. BuildSingleCylinder();
  1224. BuildDoubleCylinder();
  1225. BuildElbow();
  1226. BuildLogo();
  1227. }
  1228. static void Init(void)
  1229. {
  1230. static float ambient[] = {0.1, 0.1, 0.1, 1.0};
  1231. static float diffuse[] = {0.5, 1.0, 1.0, 1.0};
  1232. static float position[] = {90.0, 90.0, 150.0, 0.0};
  1233. static float front_mat_shininess[] = {30.0};
  1234. static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0};
  1235. static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0};
  1236. static float back_mat_shininess[] = {50.0};
  1237. static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0};
  1238. static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0};
  1239. static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
  1240. static float lmodel_twoside[] = {GL_TRUE};
  1241. glClearColor(0.0, 0.0, 0.0, 0.0);
  1242. glFrontFace(GL_CW);
  1243. glDepthFunc(GL_LEQUAL);
  1244. glEnable(GL_DEPTH_TEST);
  1245. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  1246. glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
  1247. glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  1248. glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  1249. glLightfv(GL_LIGHT0, GL_POSITION, position);
  1250. glEnable(GL_LIGHTING);
  1251. glEnable(GL_LIGHT0);
  1252. glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);
  1253. glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular);
  1254. glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse);
  1255. glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess);
  1256. glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular);
  1257. glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse);
  1258. glEnable(GL_CLIP_PLANE0);
  1259. if (rgb) {
  1260. glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal);
  1261. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat);
  1262. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat);
  1263. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest);
  1264. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest);
  1265. glTexImage2D(GL_TEXTURE_2D, 0, 3, CHECKIMAGEWIDTH, CHECKIMAGEHEIGHT, 0,
  1266. GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)checkImage);
  1267. glEnable(GL_TEXTURE_2D);
  1268. glCullFace(GL_BACK);
  1269. glEnable(GL_CULL_FACE);
  1270. } else {
  1271. tkSetGreyRamp();
  1272. if (doubleBuffer) {
  1273. colorIndexes[1] = 10;
  1274. colorIndexes[2] = 15;
  1275. }
  1276. glMaterialiv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES, colorIndexes);
  1277. }
  1278. BuildLists();
  1279. dithering = GL_TRUE;
  1280. shade = GL_TRUE;
  1281. doStipple = GL_FALSE;
  1282. polyMode = GL_BACK;
  1283. }
  1284. static void Reshape(int width, int height)
  1285. {
  1286. glViewport(0, 0, (GLint)width, (GLint)height);
  1287. glMatrixMode(GL_PROJECTION);
  1288. glLoadIdentity();
  1289. gluPerspective(90, 1.0, 1.0, 200.0);
  1290. glMatrixMode(GL_MODELVIEW);
  1291. }
  1292. static GLenum Key(int key, GLenum mask)
  1293. {
  1294. switch (key) {
  1295. case TK_ESCAPE:
  1296. tkQuit();
  1297. case TK_LEFT:
  1298. yRotation += 0.5;
  1299. break;
  1300. case TK_RIGHT:
  1301. yRotation -= 0.5;
  1302. break;
  1303. case TK_UP:
  1304. plane[3] += 2.0;
  1305. break;
  1306. case TK_DOWN:
  1307. plane[3] -= 2.0;
  1308. break;
  1309. case TK_Z:
  1310. zTranslation -= 1.0;
  1311. break;
  1312. case TK_z:
  1313. zTranslation += 1.0;
  1314. break;
  1315. case TK_1:
  1316. glPolygonMode(polyMode, GL_POINT);
  1317. break;
  1318. case TK_2:
  1319. glPolygonMode(polyMode, GL_LINE);
  1320. break;
  1321. case TK_3:
  1322. glPolygonMode(polyMode, GL_FILL);
  1323. break;
  1324. case TK_p:
  1325. switch (polyMode) {
  1326. case GL_BACK:
  1327. polyMode = GL_FRONT;
  1328. break;
  1329. case GL_FRONT:
  1330. polyMode = GL_FRONT_AND_BACK;
  1331. break;
  1332. case GL_FRONT_AND_BACK:
  1333. polyMode = GL_BACK;
  1334. break;
  1335. }
  1336. break;
  1337. case TK_4:
  1338. glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
  1339. break;
  1340. case TK_5:
  1341. glEnable(GL_POLYGON_SMOOTH);
  1342. if (rgb) {
  1343. glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  1344. glEnable(GL_BLEND);
  1345. glDisable(GL_DEPTH_TEST);
  1346. } else {
  1347. SetUpAntiAliasedGrayScale();
  1348. }
  1349. break;
  1350. case TK_6:
  1351. glDisable(GL_POLYGON_SMOOTH);
  1352. if (rgb) {
  1353. glBlendFunc(GL_ONE, GL_ZERO);
  1354. glDisable(GL_BLEND);
  1355. glEnable(GL_DEPTH_TEST);
  1356. } else {
  1357. tkSetGreyRamp();
  1358. }
  1359. break;
  1360. case TK_8:
  1361. dithering = !dithering;
  1362. (dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER);
  1363. break;
  1364. case TK_9:
  1365. doStipple = !doStipple;
  1366. if (doStipple) {
  1367. glPolygonStipple(stipple);
  1368. glEnable(GL_POLYGON_STIPPLE);
  1369. } else {
  1370. glDisable(GL_POLYGON_STIPPLE);
  1371. }
  1372. break;
  1373. case TK_0:
  1374. shade = !shade;
  1375. (shade) ? glShadeModel(GL_SMOOTH) : glShadeModel(GL_FLAT);
  1376. break;
  1377. case TK_q:
  1378. glDisable(GL_CULL_FACE);
  1379. break;
  1380. case TK_w:
  1381. glEnable(GL_CULL_FACE);
  1382. glCullFace(GL_FRONT);
  1383. break;
  1384. case TK_e:
  1385. glEnable(GL_CULL_FACE);
  1386. glCullFace(GL_BACK);
  1387. break;
  1388. case TK_r:
  1389. glFrontFace(GL_CW);
  1390. break;
  1391. case TK_t:
  1392. glFrontFace(GL_CCW);
  1393. break;
  1394. case TK_y:
  1395. glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  1396. glPixelStorei(GL_UNPACK_LSB_FIRST, 0);
  1397. glPolygonStipple(stipple);
  1398. break;
  1399. case TK_u:
  1400. glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  1401. glPixelStorei(GL_UNPACK_LSB_FIRST, 1);
  1402. glPolygonStipple(stipple);
  1403. break;
  1404. case TK_a:
  1405. glEnable(GL_TEXTURE_2D);
  1406. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat);
  1407. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat);
  1408. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest);
  1409. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest);
  1410. glTexImage2D(GL_TEXTURE_2D, 0, 4, BRICKIMAGEWIDTH,
  1411. BRICKIMAGEHEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE,
  1412. (GLvoid *)brickImage);
  1413. break;
  1414. case TK_s:
  1415. glEnable(GL_TEXTURE_2D);
  1416. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat);
  1417. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat);
  1418. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest);
  1419. glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest);
  1420. glTexImage2D(GL_TEXTURE_2D, 0, 3, CHECKIMAGEWIDTH,
  1421. CHECKIMAGEHEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE,
  1422. (GLvoid *)checkImage);
  1423. break;
  1424. case TK_d:
  1425. glDisable(GL_TEXTURE_2D);
  1426. break;
  1427. case TK_f:
  1428. glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal);
  1429. break;
  1430. case TK_g:
  1431. glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, modulate);
  1432. break;
  1433. default:
  1434. return GL_FALSE;
  1435. }
  1436. return GL_TRUE;
  1437. }
  1438. static void Draw(void)
  1439. {
  1440. glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  1441. glPushMatrix();
  1442. glTranslatef(0, 0, zTranslation);
  1443. glRotatef(30.0, 1, 0, 0);
  1444. glRotatef(yRotation, 0, 1, 0);
  1445. glClipPlane(GL_CLIP_PLANE0, plane);
  1446. glCallList(logo);
  1447. glPopMatrix();
  1448. glFlush();
  1449. if (doubleBuffer) {
  1450. tkSwapBuffers();
  1451. }
  1452. }
  1453. static GLenum Args(int argc, char **argv)
  1454. {
  1455. GLint i;
  1456. rgb = GL_TRUE;
  1457. doubleBuffer = GL_TRUE;
  1458. directRender = GL_FALSE;
  1459. for (i = 1; i < argc; i++) {
  1460. if (strcmp(argv[i], "-ci") == 0) {
  1461. rgb = GL_FALSE;
  1462. } else if (strcmp(argv[i], "-rgb") == 0) {
  1463. rgb = GL_TRUE;
  1464. } else if (strcmp(argv[i], "-sb") == 0) {
  1465. doubleBuffer = GL_FALSE;
  1466. } else if (strcmp(argv[i], "-db") == 0) {
  1467. doubleBuffer = GL_TRUE;
  1468. } else if (strcmp(argv[i], "-dr") == 0) {
  1469. directRender = GL_TRUE;
  1470. } else if (strcmp(argv[i], "-ir") == 0) {
  1471. directRender = GL_FALSE;
  1472. } else {
  1473. printf("%s (Bad option).\n", argv[i]);
  1474. return GL_FALSE;
  1475. }
  1476. }
  1477. return GL_TRUE;
  1478. }
  1479. void main(int argc, char **argv)
  1480. {
  1481. GLenum type;
  1482. if (Args(argc, argv) == GL_FALSE) {
  1483. tkQuit();
  1484. }
  1485. tkInitPosition(0, 0, 300, 300);
  1486. type = TK_DEPTH16;
  1487. type |= (rgb) ? TK_RGB : TK_INDEX;
  1488. type |= (doubleBuffer) ? TK_DOUBLE : TK_SINGLE;
  1489. type |= (directRender) ? TK_DIRECT : TK_INDIRECT;
  1490. tkInitDisplayMode(type);
  1491. if (tkInitWindow("Logo Test") == GL_FALSE) {
  1492. tkQuit();
  1493. }
  1494. Init();
  1495. tkExposeFunc(Reshape);
  1496. tkReshapeFunc(Reshape);
  1497. tkKeyDownFunc(Key);
  1498. tkDisplayFunc(Draw);
  1499. tkExec();
  1500. }