Advertisement
sazzad15

batman,CG

Oct 17th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.33 KB | None | 0 0
  1. #include <GL/gl.h>
  2. #include <GL/glut.h>
  3.  
  4. int x = 0, y = 0;
  5.  
  6.  
  7. void yellowbox(int x,int y,int w,int h)
  8. {
  9. glColor3f(255,255,0);
  10.  
  11. glBegin(GL_POLYGON);
  12. glVertex2i(x,y);
  13. glVertex2i(x+w,y);
  14. glVertex2i(x+w,y+h);
  15. glVertex2i(x,y+h);
  16. glEnd();
  17. }
  18.  
  19. void blackbox(int x,int y,int w,int h)
  20. {
  21. glColor3f(0,0,0);
  22.  
  23. glBegin(GL_POLYGON);
  24. glVertex2i(x,y);
  25. glVertex2i(x+w,y);
  26. glVertex2i(x+w,y+h);
  27. glVertex2i(x,y+h);
  28. glEnd();
  29. }
  30.  
  31.  
  32. void display(void)
  33. {
  34. int w = 20, h = 20;
  35. glClear(GL_COLOR_BUFFER_BIT);
  36. for(;x<=690;x+=21){
  37. for(y=0;y<=500;y+=21){
  38.  
  39. glColor3f(1,1,1);
  40.  
  41. glBegin(GL_POLYGON);
  42. glVertex2i(x,y);
  43. glVertex2i(x+w,y);
  44. glVertex2i(x+w,y+h);
  45. glVertex2i(x,y+h);
  46. glEnd();
  47. }
  48. }
  49.  
  50. /// 1St Line
  51. for(y=189;y<340;y+=21){
  52. glColor3f(0,0,0);
  53.  
  54. glBegin(GL_POLYGON);
  55. glVertex2i(21,y);
  56. glVertex2i(21+w,y);
  57. glVertex2i(21+w,y+h);
  58. glVertex2i(21,y+h);
  59. glEnd();
  60. }
  61.  
  62. ///2nd Line
  63. for(y=189;y<340;y+=21){
  64. glColor3f(255,255,0);
  65.  
  66. glBegin(GL_POLYGON);
  67. glVertex2i(42,y);
  68. glVertex2i(42+w,y);
  69. glVertex2i(42+w,y+h);
  70. glVertex2i(42,y+h);
  71. glEnd();
  72. }
  73.  
  74. blackbox(42,168,w,h);
  75. blackbox(42,357,w,h);
  76.  
  77. /// 3rd Line
  78. for(y=210;y<320;y+=21){
  79. glColor3f(0,0,0);
  80.  
  81. glBegin(GL_POLYGON);
  82. glVertex2i(63,y);
  83. glVertex2i(63+w,y);
  84. glVertex2i(63+w,y+h);
  85. glVertex2i(63,y+h);
  86. glEnd();
  87. }
  88. yellowbox(63,189,w,h);
  89. yellowbox(63,168,w,h);
  90. yellowbox(63,336,w,h);
  91. yellowbox(63,357,w,h);
  92. blackbox(63,378,w,h);
  93. blackbox(63,147,w,h);
  94.  
  95. // 4th LINE
  96. for(y=189;y<340;y+=21){
  97. glColor3f(0,0,0);
  98.  
  99. glBegin(GL_POLYGON);
  100. glVertex2i(84,y);
  101. glVertex2i(84+w,y);
  102. glVertex2i(84+w,y+h);
  103. glVertex2i(84,y+h);
  104. glEnd();
  105. }
  106. yellowbox(84,147,w,h);
  107. yellowbox(84,168,w,h);
  108. blackbox(84,126,w,h);
  109. yellowbox(84,357,w,h);
  110. yellowbox(84,378,w,h);
  111. blackbox(84,399,w,h);
  112.  
  113. // 5th LINE************
  114. for(y=168;y<360;y+=21){
  115. glColor3f(0,0,0);
  116.  
  117. glBegin(GL_POLYGON);
  118. glVertex2i(105,y);
  119. glVertex2i(105+w,y);
  120. glVertex2i(105+w,y+h);
  121. glVertex2i(105,y+h);
  122. glEnd();
  123. }
  124. yellowbox(105,126,w,h);
  125. yellowbox(105,147,w,h);
  126. blackbox(105,105,w,h);
  127. yellowbox(105,378,w,h);
  128. yellowbox(105,399,w,h);
  129. blackbox(105,420,w,h);
  130.  
  131. //6th LINE
  132.  
  133. for(y=147;y<380;y+=21){
  134. glColor3f(0,0,0);
  135.  
  136. glBegin(GL_POLYGON);
  137. glVertex2i(126,y);
  138. glVertex2i(126+w,y);
  139. glVertex2i(126+w,y+h);
  140. glVertex2i(126,y+h);
  141. glEnd();
  142. }
  143. yellowbox(126,105,w,h);
  144. yellowbox(126,126,w,h);
  145. blackbox(126,84,w,h);
  146. yellowbox(126,399,w,h);
  147. yellowbox(126,420,w,h);
  148. blackbox(126,441,w,h);
  149.  
  150. //7th Line
  151. for(y=126;y<400;y+=21){
  152. glColor3f(0,0,0);
  153.  
  154. glBegin(GL_POLYGON);
  155. glVertex2i(147,y);
  156. glVertex2i(147+w,y);
  157. glVertex2i(147+w,y+h);
  158. glVertex2i(147,y+h);
  159. glEnd();
  160. }
  161. yellowbox(147,84,w,h);
  162. yellowbox(147,105,w,h);
  163. blackbox(147,63,w,h);
  164. yellowbox(147,420,w,h);
  165. yellowbox(147,441,w,h);
  166. blackbox(147,462,w,h);
  167.  
  168. //8th Line
  169. for(y=105;y<440;y+=21){
  170. glColor3f(0,0,0);
  171.  
  172. glBegin(GL_POLYGON);
  173. glVertex2i(168,y);
  174. glVertex2i(168+w,y);
  175. glVertex2i(168+w,y+h);
  176. glVertex2i(168,y+h);
  177. glEnd();
  178. }
  179. yellowbox(168,63,w,h);
  180. yellowbox(168,84,w,h);
  181. blackbox(168,42,w,h);
  182. yellowbox(168,441,w,h);
  183. yellowbox(168,462,w,h);
  184. blackbox(168,483,w,h);
  185.  
  186. //9th LINE
  187.  
  188. for(y=105;y<440;y+=21){
  189. glColor3f(0,0,0);
  190.  
  191. glBegin(GL_POLYGON);
  192. glVertex2i(189,y);
  193. glVertex2i(189+w,y);
  194. glVertex2i(189+w,y+h);
  195. glVertex2i(189,y+h);
  196. glEnd();
  197. }
  198. yellowbox(189,63,w,h);
  199. yellowbox(189,84,w,h);
  200. blackbox(189,42,w,h);
  201. yellowbox(189,441,w,h);
  202. yellowbox(189,462,w,h);
  203. blackbox(189,483,w,h);
  204.  
  205. // 10th Line
  206.  
  207. for(y=84;y<340;y+=21){
  208. glColor3f(0,0,0);
  209.  
  210. glBegin(GL_POLYGON);
  211. glVertex2i(210,y);
  212. glVertex2i(210+w,y);
  213. glVertex2i(210+w,y+h);
  214. glVertex2i(210,y+h);
  215. glEnd();
  216. }
  217. yellowbox(210,63,w,h);
  218. blackbox(210,42,w,h);
  219. yellowbox(210,357,w,h);
  220. yellowbox(210,378,w,h);
  221. yellowbox(210,399,w,h);
  222. blackbox(210,420,w,h);
  223. yellowbox(210,441,w,h);
  224. yellowbox(210,462,w,h);
  225. blackbox(210,483,w,h);
  226.  
  227. //11th LINE
  228. for(y=126;y<320;y+=21){
  229. glColor3f(0,0,0);
  230.  
  231. glBegin(GL_POLYGON);
  232. glVertex2i(231,y);
  233. glVertex2i(231+w,y);
  234. glVertex2i(231+w,y+h);
  235. glVertex2i(231,y+h);
  236. glEnd();
  237. }
  238. yellowbox(231,63,w,h);
  239. yellowbox(231,84,w,h);
  240. yellowbox(231,105,w,h);
  241. blackbox(231,42,w,h);
  242. blackbox(231,483,w,h);
  243.  
  244. for(y=336;y<480;y+=21){
  245. glColor3f(255,255,0);
  246.  
  247. glBegin(GL_POLYGON);
  248. glVertex2i(231,y);
  249. glVertex2i(231+w,y);
  250. glVertex2i(231+w,y+h);
  251. glVertex2i(231,y+h);
  252. glEnd();
  253. }
  254.  
  255. //12th LINE ****
  256. for(y=147;y<300;y+=21){
  257. glColor3f(0,0,0);
  258.  
  259. glBegin(GL_POLYGON);
  260. glVertex2i(252,y);
  261. glVertex2i(252+w,y);
  262. glVertex2i(252+w,y+h);
  263. glVertex2i(252,y+h);
  264. glEnd();
  265. }
  266.  
  267. for(y=336;y<480;y+=21){
  268. glColor3f(255,255,0);
  269.  
  270. glBegin(GL_POLYGON);
  271. glVertex2i(252,y);
  272. glVertex2i(252+w,y);
  273. glVertex2i(252+w,y+h);
  274. glVertex2i(252,y+h);
  275. glEnd();
  276. }
  277. blackbox(252,483,w,h);
  278. yellowbox(252,63,w,h);
  279. yellowbox(252,84,w,h);
  280. yellowbox(252,105,w,h);
  281. yellowbox(252,126,w,h);
  282. blackbox(252,42,w,h);
  283. blackbox(252,315,w,h);
  284.  
  285.  
  286.  
  287. //13th Line
  288. for(y=357;y<480;y+=21){
  289. glColor3f(255,255,0);
  290.  
  291. glBegin(GL_POLYGON);
  292. glVertex2i(273,y);
  293. glVertex2i(273+w,y);
  294. glVertex2i(273+w,y+h);
  295. glVertex2i(273,y+h);
  296. glEnd();
  297. }
  298.  
  299. for(y=168;y<340;y+=21){
  300. glColor3f(0,0,0);
  301.  
  302. glBegin(GL_POLYGON);
  303. glVertex2i(273,y);
  304. glVertex2i(273+w,y);
  305. glVertex2i(273+w,y+h);
  306. glVertex2i(273,y+h);
  307. glEnd();
  308. }
  309.  
  310. for(y=63;y<160;y+=21){
  311. glColor3f(255,255,0);
  312.  
  313. glBegin(GL_POLYGON);
  314. glVertex2i(273,y);
  315. glVertex2i(273+w,y);
  316. glVertex2i(273+w,y+h);
  317. glVertex2i(273,y+h);
  318. glEnd();
  319. }
  320. blackbox(273,42,w,h);
  321. blackbox(273,483,w,h);
  322.  
  323. //14th Line
  324.  
  325. for(y=147;y<460;y+=21){
  326. glColor3f(0,0,0);
  327.  
  328. glBegin(GL_POLYGON);
  329. glVertex2i(294,y);
  330. glVertex2i(294+w,y);
  331. glVertex2i(294+w,y+h);
  332. glVertex2i(294,y+h);
  333. glEnd();
  334. }
  335.  
  336. for(y=63;y<140;y+=21){
  337. glColor3f(255,255,0);
  338.  
  339. glBegin(GL_POLYGON);
  340. glVertex2i(294,y);
  341. glVertex2i(294+w,y);
  342. glVertex2i(294+w,y+h);
  343. glVertex2i(294,y+h);
  344. glEnd();
  345. }
  346. blackbox(294,42,w,h);
  347. blackbox(294,483,w,h);
  348. yellowbox(294,462,w,h);
  349.  
  350. //15th Line
  351. for(y=105;y<440;y+=21){
  352. glColor3f(0,0,0);
  353.  
  354. glBegin(GL_POLYGON);
  355. glVertex2i(315,y);
  356. glVertex2i(315+w,y);
  357. glVertex2i(315+w,y+h);
  358. glVertex2i(315,y+h);
  359. glEnd();
  360. }
  361. blackbox(315,42,w,h);
  362. blackbox(315,483,w,h);
  363. yellowbox(315,63,w,h);
  364. yellowbox(315,84,w,h);
  365. yellowbox(315,462,w,h);
  366. yellowbox(315,441,w,h);
  367.  
  368. //16th Line
  369. for(y=84;y<440;y+=21){
  370. glColor3f(0,0,0);
  371.  
  372. glBegin(GL_POLYGON);
  373. glVertex2i(336,y);
  374. glVertex2i(336+w,y);
  375. glVertex2i(336+w,y+h);
  376. glVertex2i(336,y+h);
  377. glEnd();
  378. }
  379. blackbox(336,42,w,h);
  380. blackbox(336,483,w,h);
  381. yellowbox(336,63,w,h);
  382. yellowbox(336,462,w,h);
  383. yellowbox(336,441,w,h);
  384.  
  385. //17th Line 15
  386. for(y=105;y<440;y+=21){
  387. glColor3f(0,0,0);
  388.  
  389. glBegin(GL_POLYGON);
  390. glVertex2i(357,y);
  391. glVertex2i(357+w,y);
  392. glVertex2i(357+w,y+h);
  393. glVertex2i(357,y+h);
  394. glEnd();
  395. }
  396. blackbox(357,42,w,h);
  397. blackbox(357,483,w,h);
  398. yellowbox(357,63,w,h);
  399. yellowbox(357,84,w,h);
  400. yellowbox(357,462,w,h);
  401. yellowbox(357,441,w,h);
  402.  
  403. //18th Line 14
  404. for(y=147;y<460;y+=21){
  405. glColor3f(0,0,0);
  406.  
  407. glBegin(GL_POLYGON);
  408. glVertex2i(378,y);
  409. glVertex2i(378+w,y);
  410. glVertex2i(378+w,y+h);
  411. glVertex2i(378,y+h);
  412. glEnd();
  413. }
  414.  
  415. for(y=63;y<140;y+=21){
  416. glColor3f(255,255,0);
  417.  
  418. glBegin(GL_POLYGON);
  419. glVertex2i(378,y);
  420. glVertex2i(378+w,y);
  421. glVertex2i(378+w,y+h);
  422. glVertex2i(378,y+h);
  423. glEnd();
  424. }
  425. blackbox(378,42,w,h);
  426. blackbox(378,483,w,h);
  427. yellowbox(378,462,w,h);
  428.  
  429. //19th Line 13
  430. for(y=357;y<480;y+=21){
  431. glColor3f(255,255,0);
  432.  
  433. glBegin(GL_POLYGON);
  434. glVertex2i(399,y);
  435. glVertex2i(399+w,y);
  436. glVertex2i(399+w,y+h);
  437. glVertex2i(399,y+h);
  438. glEnd();
  439. }
  440.  
  441. for(y=168;y<340;y+=21){
  442. glColor3f(0,0,0);
  443.  
  444. glBegin(GL_POLYGON);
  445. glVertex2i(399,y);
  446. glVertex2i(399+w,y);
  447. glVertex2i(399+w,y+h);
  448. glVertex2i(399,y+h);
  449. glEnd();
  450. }
  451.  
  452. for(y=63;y<160;y+=21){
  453. glColor3f(255,255,0);
  454.  
  455. glBegin(GL_POLYGON);
  456. glVertex2i(399,y);
  457. glVertex2i(399+w,y);
  458. glVertex2i(399+w,y+h);
  459. glVertex2i(399,y+h);
  460. glEnd();
  461. }
  462. blackbox(399,42,w,h);
  463. blackbox(399,483,w,h);
  464.  
  465. //20th Line 12
  466. for(y=147;y<300;y+=21){
  467. glColor3f(0,0,0);
  468.  
  469. glBegin(GL_POLYGON);
  470. glVertex2i(420,y);
  471. glVertex2i(420+w,y);
  472. glVertex2i(420+w,y+h);
  473. glVertex2i(420,y+h);
  474. glEnd();
  475. }
  476.  
  477. for(y=336;y<480;y+=21){
  478. glColor3f(255,255,0);
  479.  
  480. glBegin(GL_POLYGON);
  481. glVertex2i(420,y);
  482. glVertex2i(420+w,y);
  483. glVertex2i(420+w,y+h);
  484. glVertex2i(420,y+h);
  485. glEnd();
  486. }
  487. blackbox(420,483,w,h);
  488. yellowbox(420,63,w,h);
  489. yellowbox(420,84,w,h);
  490. yellowbox(420,105,w,h);
  491. yellowbox(420,126,w,h);
  492. blackbox(420,42,w,h);
  493. blackbox(420,315,w,h);
  494.  
  495. //21th Line 11
  496. for(y=126;y<320;y+=21){
  497. glColor3f(0,0,0);
  498.  
  499. glBegin(GL_POLYGON);
  500. glVertex2i(441,y);
  501. glVertex2i(441+w,y);
  502. glVertex2i(441+w,y+h);
  503. glVertex2i(441,y+h);
  504. glEnd();
  505. }
  506. yellowbox(441,63,w,h);
  507. yellowbox(441,84,w,h);
  508. yellowbox(441,105,w,h);
  509. blackbox(441,42,w,h);
  510. blackbox(441,483,w,h);
  511.  
  512. for(y=336;y<480;y+=21){
  513. glColor3f(255,255,0);
  514.  
  515. glBegin(GL_POLYGON);
  516. glVertex2i(441,y);
  517. glVertex2i(441+w,y);
  518. glVertex2i(441+w,y+h);
  519. glVertex2i(441,y+h);
  520. glEnd();
  521. }
  522.  
  523. //22th Line 10
  524. for(y=84;y<340;y+=21){
  525. glColor3f(0,0,0);
  526.  
  527. glBegin(GL_POLYGON);
  528. glVertex2i(462,y);
  529. glVertex2i(462+w,y);
  530. glVertex2i(462+w,y+h);
  531. glVertex2i(462,y+h);
  532. glEnd();
  533. }
  534. yellowbox(462,63,w,h);
  535. blackbox(462,42,w,h);
  536. yellowbox(462,357,w,h);
  537. yellowbox(462,378,w,h);
  538. yellowbox(462,399,w,h);
  539. blackbox(462,420,w,h);
  540. yellowbox(462,441,w,h);
  541. yellowbox(462,462,w,h);
  542. blackbox(462,483,w,h);
  543.  
  544. //23th Line 9
  545. for(y=105;y<440;y+=21){
  546. glColor3f(0,0,0);
  547.  
  548. glBegin(GL_POLYGON);
  549. glVertex2i(483,y);
  550. glVertex2i(483+w,y);
  551. glVertex2i(483+w,y+h);
  552. glVertex2i(483,y+h);
  553. glEnd();
  554. }
  555. yellowbox(483,63,w,h);
  556. yellowbox(483,84,w,h);
  557. blackbox(483,42,w,h);
  558. yellowbox(483,441,w,h);
  559. yellowbox(483,462,w,h);
  560. blackbox(483,483,w,h);
  561.  
  562. //24th Line 8
  563. for(y=105;y<440;y+=21){
  564. glColor3f(0,0,0);
  565.  
  566. glBegin(GL_POLYGON);
  567. glVertex2i(504,y);
  568. glVertex2i(504+w,y);
  569. glVertex2i(504+w,y+h);
  570. glVertex2i(504,y+h);
  571. glEnd();
  572. }
  573. yellowbox(504,63,w,h);
  574. yellowbox(504,84,w,h);
  575. blackbox(504,42,w,h);
  576. yellowbox(504,441,w,h);
  577. yellowbox(504,462,w,h);
  578. blackbox(504,483,w,h);
  579.  
  580. //25th Line 7
  581. for(y=126;y<400;y+=21){
  582. glColor3f(0,0,0);
  583.  
  584. glBegin(GL_POLYGON);
  585. glVertex2i(525,y);
  586. glVertex2i(525+w,y);
  587. glVertex2i(525+w,y+h);
  588. glVertex2i(525,y+h);
  589. glEnd();
  590. }
  591. yellowbox(525,84,w,h);
  592. yellowbox(525,105,w,h);
  593. blackbox(525,63,w,h);
  594. yellowbox(525,420,w,h);
  595. yellowbox(525,441,w,h);
  596. blackbox(525,462,w,h);
  597.  
  598. //26th Line 6
  599. for(y=147;y<380;y+=21){
  600. glColor3f(0,0,0);
  601.  
  602. glBegin(GL_POLYGON);
  603. glVertex2i(546,y);
  604. glVertex2i(546+w,y);
  605. glVertex2i(546+w,y+h);
  606. glVertex2i(546,y+h);
  607. glEnd();
  608. }
  609. yellowbox(546,105,w,h);
  610. yellowbox(546,126,w,h);
  611. blackbox(546,84,w,h);
  612. yellowbox(546,399,w,h);
  613. yellowbox(546,420,w,h);
  614. blackbox(546,441,w,h);
  615.  
  616. //27th Line 5
  617. for(y=168;y<360;y+=21){
  618. glColor3f(0,0,0);
  619.  
  620. glBegin(GL_POLYGON);
  621. glVertex2i(567,y);
  622. glVertex2i(567+w,y);
  623. glVertex2i(567+w,y+h);
  624. glVertex2i(567,y+h);
  625. glEnd();
  626. }
  627. yellowbox(567,126,w,h);
  628. yellowbox(567,147,w,h);
  629. blackbox(567,105,w,h);
  630. yellowbox(567,378,w,h);
  631. yellowbox(567,399,w,h);
  632. blackbox(567,420,w,h);
  633.  
  634. //28th Line 4
  635. for(y=189;y<340;y+=21){
  636. glColor3f(0,0,0);
  637.  
  638. glBegin(GL_POLYGON);
  639. glVertex2i(588,y);
  640. glVertex2i(588+w,y);
  641. glVertex2i(588+w,y+h);
  642. glVertex2i(588,y+h);
  643. glEnd();
  644. }
  645. yellowbox(588,147,w,h);
  646. yellowbox(588,168,w,h);
  647. blackbox(588,126,w,h);
  648. yellowbox(588,357,w,h);
  649. yellowbox(588,378,w,h);
  650. blackbox(588,399,w,h);
  651.  
  652. //29th Line 3
  653. for(y=210;y<320;y+=21){
  654. glColor3f(0,0,0);
  655.  
  656. glBegin(GL_POLYGON);
  657. glVertex2i(609,y);
  658. glVertex2i(609+w,y);
  659. glVertex2i(609+w,y+h);
  660. glVertex2i(609,y+h);
  661. glEnd();
  662. }
  663. yellowbox(609,189,w,h);
  664. yellowbox(609,168,w,h);
  665. yellowbox(609,336,w,h);
  666. yellowbox(609,357,w,h);
  667. blackbox(609,378,w,h);
  668. blackbox(609,147,w,h);
  669.  
  670. //30th Line 2
  671.  
  672. for(y=189;y<340;y+=21){
  673. glColor3f(255,255,0);
  674.  
  675. glBegin(GL_POLYGON);
  676. glVertex2i(630,y);
  677. glVertex2i(630+w,y);
  678. glVertex2i(630+w,y+h);
  679. glVertex2i(630,y+h);
  680. glEnd();
  681. }
  682.  
  683. blackbox(630,168,w,h);
  684. blackbox(630,357,w,h);
  685.  
  686. //31th Line 1
  687. for(y=189;y<340;y+=21){
  688. glColor3f(0,0,0);
  689.  
  690. glBegin(GL_POLYGON);
  691. glVertex2i(651,y);
  692. glVertex2i(651+w,y);
  693. glVertex2i(651+w,y+h);
  694. glVertex2i(651,y+h);
  695. glEnd();
  696. }
  697.  
  698. glFlush();
  699. }
  700. void init(void)
  701. {
  702. glClearColor(1.0, 0.0, 1.0, 0.0);
  703. glMatrixMode(GL_PROJECTION);
  704. glLoadIdentity();
  705. gluOrtho2D(0,690,0,500);
  706. }
  707. int main(int argc, char** argv)
  708. {
  709. glutInit(&argc, argv);
  710. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  711. glutInitWindowSize(690, 500);
  712. glutInitWindowPosition(100, 100);
  713. glutCreateWindow("BATMAN");
  714. init();
  715. glutDisplayFunc(display);
  716. glutMainLoop();
  717. return 0;
  718. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement