Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.72 KB | None | 0 0
  1. #include<windows.h>
  2. #include <math.h>
  3. #include <GL/glut.h>
  4. //#include <fstream.h>
  5. #include <stdlib.h>
  6.  
  7. typedef struct {
  8. float m[4][4];
  9. } matrix3D_t;
  10.  
  11. typedef struct {
  12. float v[4];
  13. } vector3D_t;
  14.  
  15. typedef struct {
  16. float x;
  17. float y;
  18. float z;
  19. } point3D_t;
  20.  
  21. typedef struct {
  22. float x;
  23. float y;
  24. } point2D_t;
  25.  
  26. typedef struct {
  27. float r;
  28. float g;
  29. float b;
  30. } color_t;
  31.  
  32. ////////////////// matrices and vectors 3D ver 2 /////////////////
  33. matrix3D_t createIdentity(void)
  34. {
  35. matrix3D_t u;
  36. int i,j;
  37. for (i=0;i<4;i++) {
  38. for(j=0;j<4;j++) u.m[i][j]=0.;
  39. u.m[i][i]=1.;
  40. }
  41. return u;
  42. }
  43.  
  44. matrix3D_t operator * (matrix3D_t a,matrix3D_t b)
  45. {
  46. matrix3D_t c;//c=a*b
  47. int i,j,k;
  48. for (i=0;i<4;i++) for (j=0;j<4;j++) {
  49. c.m[i][j]=0;
  50. for (k=0;k<4;k++) c.m[i][j]+=a.m[i][k]*b.m[k][j];
  51. }
  52. return c;
  53. }
  54.  
  55. vector3D_t operator * (matrix3D_t a, vector3D_t b)
  56. {
  57. vector3D_t c;//c=a*b
  58. int i,j;
  59. for (i=0;i<4;i++) {
  60. c.v[i]=0;
  61. for (j=0;j<4;j++) c.v[i]+=a.m[i][j]*b.v[j];
  62. }
  63. return c;
  64. }
  65.  
  66. matrix3D_t translationMTX(float dx,float dy,float dz)
  67. {
  68. matrix3D_t trans=createIdentity();
  69. trans.m[0][3]=dx;
  70. trans.m[1][3]=dy;
  71. trans.m[2][3]=dz;
  72. return trans;
  73. }
  74.  
  75. matrix3D_t rotationXMTX(float theta)
  76. {
  77. matrix3D_t rotate=createIdentity();
  78. float cs=cos(theta);
  79. float sn=sin(theta);
  80. rotate.m[1][1]=cs; rotate.m[1][2]=-sn;
  81. rotate.m[2][1]=sn; rotate.m[2][2]=cs;
  82. return rotate;
  83. }
  84.  
  85. matrix3D_t rotationYMTX(float theta)
  86. {
  87. matrix3D_t rotate=createIdentity();
  88. float cs=cos(theta);
  89. float sn=sin(theta);
  90. rotate.m[0][0]=cs; rotate.m[0][2]=sn;
  91. rotate.m[2][0]=-sn; rotate.m[2][2]=cs;
  92. return rotate;
  93. }
  94.  
  95. matrix3D_t rotationZMTX(float theta)
  96. {
  97. matrix3D_t rotate=createIdentity();
  98. float cs=cos(theta);
  99. float sn=sin(theta);
  100. rotate.m[0][0]=cs; rotate.m[0][1]=-sn;
  101. rotate.m[1][0]=sn; rotate.m[1][1]=cs;
  102. return rotate;
  103. }
  104.  
  105. matrix3D_t scalingMTX(float factorx,float factory,float factorz)
  106. {
  107. matrix3D_t scale=createIdentity();
  108. scale.m[0][0]=factorx;
  109. scale.m[1][1]=factory;
  110. scale.m[2][2]=factorz;
  111. return scale;
  112. }
  113.  
  114. matrix3D_t perspectiveMTX(float eyelength)
  115. {
  116. matrix3D_t perspective=createIdentity();
  117. perspective.m[3][2]=-1./eyelength;
  118. return perspective;
  119. }
  120.  
  121. point2D_t Vector2Point2D(vector3D_t vec)
  122. {
  123. point2D_t pnt;
  124. pnt.x=vec.v[0];
  125. pnt.y=vec.v[1];
  126. return pnt;
  127. }
  128.  
  129. point3D_t Vector2Point3D(vector3D_t vec)
  130. {
  131. point3D_t pnt;
  132. pnt.x=vec.v[0];
  133. pnt.y=vec.v[1];
  134. pnt.z=vec.v[2];
  135. return pnt;
  136. }
  137.  
  138. vector3D_t Point2Vector(point3D_t pnt)
  139. {
  140. vector3D_t vec;
  141. vec.v[0]=pnt.x;
  142. vec.v[1]=pnt.y;
  143. vec.v[2]=pnt.z;
  144. vec.v[3]=1.;
  145. return vec;
  146. }
  147.  
  148. vector3D_t homogenizeVector(vector3D_t vec)
  149. {
  150. int i;
  151. for (i=0;i<3;i++) {
  152. vec.v[i]/=vec.v[3];
  153. }
  154. vec.v[3]=1.;
  155. return vec;
  156. }
  157.  
  158. vector3D_t unitVector(vector3D_t vec)
  159. {
  160. int i;
  161. float vec2=0.;
  162. float vec1,invvec1;
  163. for (i=0;i<3;i++) {
  164. vec2+=vec.v[i]*vec.v[i];
  165. }
  166. vec1=sqrt(vec2);
  167. if (vec1!=0.) {
  168. invvec1=1./vec1;
  169. for (i=0;i<3;i++) {
  170. vec.v[i]*=invvec1;
  171. }
  172. }
  173. vec.v[3]=1.;
  174. return vec;
  175. }
  176.  
  177. // inner product (dot product) of homogeneous vector
  178. float operator * (vector3D_t a, vector3D_t b)
  179. {
  180. float c;//c=a*b
  181. int i;
  182. c=0;
  183. for (i=0;i<3;i++) {
  184. c+=a.v[i]*b.v[i];
  185. }
  186. return c;
  187. }
  188.  
  189. // outer product (cross product ) of homogeneous vector
  190. // i j k
  191. // a0 a1 a2
  192. // b0 b1 b2
  193. vector3D_t operator ^ (vector3D_t a, vector3D_t b)
  194. {
  195. vector3D_t c;//c=a*b
  196. c.v[0]=a.v[1]*b.v[2]-a.v[2]*b.v[1];
  197. c.v[1]=a.v[2]*b.v[0]-a.v[0]*b.v[2];
  198. c.v[2]=a.v[0]*b.v[1]-a.v[1]*b.v[0];
  199. c.v[3]=1.;
  200. return c;
  201. }
  202.  
  203. vector3D_t operator - (vector3D_t v1,vector3D_t v0)
  204. {
  205. vector3D_t c;//c=v1-v0
  206. c.v[0]=v1.v[0]-v0.v[0];
  207. c.v[1]=v1.v[1]-v0.v[1];
  208. c.v[2]=v1.v[2]-v0.v[2];
  209. c.v[3]=1.;
  210. return c;
  211. }
  212.  
  213. vector3D_t operator - (vector3D_t v)
  214. {
  215. vector3D_t c;//c=-v
  216. c.v[0]=-v.v[0];
  217. c.v[1]=-v.v[1];
  218. c.v[2]=-v.v[2];
  219. c.v[3]=1.;
  220. return c;
  221. }
  222.  
  223. vector3D_t operator * (float r, vector3D_t b)
  224. {
  225. vector3D_t c;//c=r*b
  226. int i;
  227. for (i=0;i<3;i++) {
  228. c.v[i]=r*b.v[i];
  229. }
  230. c.v[3]=1.;
  231. return c;
  232. }
  233.  
  234. vector3D_t operator * (vector3D_t b, float r)
  235. {
  236. vector3D_t c;//c=r*b
  237. int i;
  238. for (i=0;i<3;i++) {
  239. c.v[i]=r*b.v[i];
  240. }
  241. c.v[3]=1.;
  242. return c;
  243. }
  244.  
  245. float funcPositive(float x)
  246. {
  247. if (0.<x) return x;
  248. else return 0.;
  249. }
  250.  
  251. // x to yth power
  252. float power(float x,float y)
  253. {
  254. //ln z = y ln x z = exp (y ln x)
  255. if (x==0.) return 0;
  256. return exp(y*log(x));
  257. }
  258.  
  259. color_t operator + (color_t c1, color_t c2)
  260. {
  261. color_t col;
  262. col.r=c1.r+c2.r;
  263. col.g=c1.g+c2.g;
  264. col.b=c1.b+c2.b;
  265. return col;
  266. }
  267.  
  268. color_t operator * (float r, color_t c)
  269. {
  270. color_t col;
  271. col.r=r*c.r;
  272. col.g=r*c.g;
  273. col.b=r*c.b;
  274. return col;
  275. }
  276.  
  277. color_t operator * (color_t c, float r)
  278. {
  279. color_t col;
  280. col.r=r*c.r;
  281. col.g=r*c.g;
  282. col.b=r*c.b;
  283. return col;
  284. }
  285.  
  286. //PhongModel color calculation
  287. // LightVector, NormalVector, ViewVector, ColorofObject
  288. color_t PhongModel(vector3D_t Light,vector3D_t Normal,vector3D_t View,color_t col)
  289. {
  290. float kspe=0.8; // specular reflection coefficient
  291. float kdif=0.5; // diffuse reflection coefficient
  292. float kamb=0.3; // ambient light coefficient
  293. float tmp,NL,RV;
  294. color_t ColWhite={1,0,0};
  295. vector3D_t ReflectionVector=(2.*(Light*Normal)*Normal)-Light;
  296. tmp=Normal*Light;
  297. NL=funcPositive(tmp);
  298. tmp=ReflectionVector*View;
  299. RV=funcPositive(tmp);
  300. return kdif*NL*col+kspe*power(RV,4)*ColWhite+kamb*col;
  301. //return kdif*NL*col+kamb*col;
  302. }
  303.  
  304. ////////////// End of matrices and vectors 3D ver 2 //////////////
  305.  
  306. ////////////// OpenGL drawShape Functions ver 1 /////////////////
  307. void setColor(float red,float green,float blue)
  308. {
  309. glColor3f(red, green, blue);
  310. }
  311.  
  312. void setColor(color_t col)
  313. {
  314. glColor3f(col.r, col.g, col.b);
  315. }
  316.  
  317. void drawDot(float x,float y)
  318. {
  319. glBegin(GL_POINTS);
  320. glVertex2f(x, y);
  321. glEnd();
  322. }
  323.  
  324. void drawLine(float x1, float y1, float x2, float y2)
  325. {
  326. glBegin(GL_LINES);
  327. glVertex2f(x1, y1);
  328. glVertex2f(x2, y2);
  329. glEnd();
  330. }
  331.  
  332. void drawLine(point2D_t p1,point2D_t p2)
  333. {
  334. drawLine(p1.x,p1.y,p2.x,p2.y);
  335. }
  336.  
  337. //n: number of points
  338. void drawPolyline(point2D_t pnt[],int n)
  339. {
  340. int i;
  341. glBegin(GL_LINE_STRIP);
  342. for (i=0;i<n;i++) {
  343. glVertex2f(pnt[i].x, pnt[i].y);
  344. }
  345. glEnd();
  346. }
  347.  
  348. //n: number of vertices
  349. void drawPolygon(point2D_t pnt[],int n)
  350. {
  351. int i;
  352. glBegin(GL_LINE_LOOP);
  353. for (i=0;i<n;i++) {
  354. glVertex2f(pnt[i].x, pnt[i].y);
  355. }
  356. glEnd();
  357. }
  358.  
  359. // The function fillPolygon can fills only convex polygons
  360. //n: number of vertices
  361. void fillPolygon(point2D_t pnt[],int n,color_t color)
  362. {
  363. int i;
  364. setColor(color);
  365. glBegin(GL_POLYGON);
  366. for (i=0;i<n;i++) {
  367. glVertex2f(pnt[i].x, pnt[i].y);
  368. }
  369. glEnd();
  370. }
  371.  
  372. // The function gradatePolygon can fills only convex polygons
  373. // The vertices will be painted with corresponding given colors.
  374. // The points inside the polygon will be painted with the mixed color.
  375. //n: number of vertices
  376. void gradatePolygon(point2D_t pnt[],int num,color_t col[])
  377. {
  378. int i;
  379. glBegin(GL_POLYGON);
  380. for (i=0;i<num;i++) {
  381. setColor(col[i]);
  382. glVertex2f(pnt[i].x, pnt[i].y);
  383. }
  384. glEnd();
  385. }
  386.  
  387. //////////// End of OpenGL drawShape Functions ver 1 ////////////
  388.  
  389. void userdraw(void);
  390.  
  391. void display(void)
  392. {
  393. glClear( GL_COLOR_BUFFER_BIT);
  394. userdraw();
  395. glutSwapBuffers();
  396. }
  397.  
  398. //////////////////////////////////////////////////////////////////
  399. void drawcharX(float x,float y)
  400. {
  401. drawLine(x,y,x+10,y+12);drawLine(x,y+12,x+10,y);
  402. }
  403.  
  404. void drawcharY(float x,float y)
  405. {
  406. drawLine(x+5,y,x+5,y+7);drawLine(x,y+12,x+5,y+7);drawLine(x+10,y+12,x+5,y+7);
  407. }
  408.  
  409. void drawcharZ(float x,float y)
  410. {
  411. drawLine(x,y+12,x+10,y+12);drawLine(x+10,y+12,x,y);drawLine(x,y,x+10,y);
  412. }
  413.  
  414. void drawAxes(matrix3D_t view)
  415. {
  416. #define HALFAXIS 220
  417. #define HALFAXIS1 (HALFAXIS-10)
  418. point3D_t axes[14]={
  419. {-HALFAXIS,0,0},{HALFAXIS,0,0},{HALFAXIS1,5,0},{HALFAXIS1,0,0},{0,0,0},
  420. {0,-HALFAXIS,0},{0,HALFAXIS,0},{0,HALFAXIS1,5},{0,HALFAXIS1,0},{0,0,0},
  421. {0,0,-HALFAXIS},{0,0,HALFAXIS},{5,0,HALFAXIS1},{0,0,HALFAXIS1}
  422. };
  423. vector3D_t vec[14];
  424. point2D_t buff[14];
  425. int i;
  426. for (i=0;i<14;i++) {
  427. vec[i]=Point2Vector(axes[i]);
  428. vec[i]=view*vec[i];
  429. buff[i]=Vector2Point2D(vec[i]);
  430. }
  431. drawPolyline(buff,14);
  432. drawcharX(buff[1].x,buff[1].y);
  433. drawcharY(buff[6].x,buff[6].y);
  434. drawcharZ(buff[11].x-14,buff[11].y);
  435. }
  436.  
  437. //////////////////////////////////////////////////////////////////
  438. typedef struct {
  439. int NumberofVertices; //in the face
  440. short int pnt[50];
  441. color_t col;
  442. } face_t;
  443. typedef struct {
  444. int NumberofVertices; //of the object
  445. point3D_t pnt[1600];
  446. color_t col[1600];
  447. int NumberofFaces; //of the object
  448. face_t fc[1000];
  449. } object3D_t;
  450.  
  451. float zRata(object3D_t obyek,matrix3D_t mat){
  452. int i;
  453. float z=0;
  454. vector3D_t vec;
  455.  
  456. for(i=0;i<obyek.NumberofVertices;i++){
  457. vec=Point2Vector(obyek.pnt[i]);
  458. vec=mat*vec;
  459. z=z+vec.v[2];
  460. }
  461. z=z/obyek.NumberofVertices;
  462. return z;
  463. }
  464.  
  465.  
  466. void draw3D(object3D_t obyek,matrix3D_t mat){
  467. vector3D_t vec[1600], vecbuff[50];
  468. vector3D_t vecNormal;
  469. point2D_t p[50];
  470. int i,j;
  471. for(i=0;i<obyek.NumberofVertices;i++){
  472. vec[i]=Point2Vector(obyek.pnt[i]);
  473. vec[i]=mat*vec[i];
  474. }
  475. setColor(1,0,0);
  476. for(i=0;i<obyek.NumberofFaces;i++){
  477. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  478. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  479. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  480. if(vecNormal.v[2]<0){
  481. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  482. p[j]=Vector2Point2D(vecbuff[j]);
  483. }
  484. drawPolygon(p,obyek.fc[i].NumberofVertices);
  485. }
  486. }
  487. setColor(1,1,1);
  488. for(i=0;i<obyek.NumberofFaces;i++){
  489. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  490. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  491. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  492. if(vecNormal.v[2]>=0){
  493. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  494. p[j]=Vector2Point2D(vecbuff[j]);
  495. }
  496. drawPolygon(p,obyek.fc[i].NumberofVertices);
  497. }
  498. }
  499. }
  500.  
  501. void draw3Da(object3D_t obyek,matrix3D_t mat){
  502. vector3D_t vec[1600], vecbuff[50];
  503. vector3D_t vecNormal;
  504. point2D_t p[50];
  505. int i,j;
  506. for(i=0;i<obyek.NumberofVertices;i++){
  507. vec[i]=Point2Vector(obyek.pnt[i]);
  508. vec[i]=mat*vec[i];
  509. }
  510. setColor(1,1,1);
  511. for(i=0;i<obyek.NumberofFaces;i++){
  512. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  513. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  514. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  515. p[j]=Vector2Point2D(vecbuff[j]);
  516. drawPolygon(p,obyek.fc[i].NumberofVertices);
  517. }
  518. }
  519.  
  520. void draw3Dw(object3D_t obyek,matrix3D_t mat,color_t col){
  521. vector3D_t vec[1600], vecbuff[50];
  522. vector3D_t vecNormal;
  523. vector3D_t lightVector={0,0,1,1},viewVector={0,0,1,1};
  524. color_t colbuff;
  525. point2D_t p[50];
  526. int i,j;
  527. for(i=0;i<obyek.NumberofVertices;i++){
  528. vec[i]=Point2Vector(obyek.pnt[i]);
  529. vec[i]=mat*vec[i];
  530. }
  531. for(i=0;i<obyek.NumberofFaces;i++){
  532. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  533. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  534. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  535. if(vecNormal.v[2]<0){
  536. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  537. p[j]=Vector2Point2D(vecbuff[j]);
  538. }
  539. vecNormal=unitVector(vecNormal);
  540. colbuff=PhongModel(lightVector,vecNormal,viewVector,col);
  541. fillPolygon(p,obyek.fc[i].NumberofVertices,colbuff);
  542. }
  543. }
  544. for(i=0;i<obyek.NumberofFaces;i++){
  545. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  546. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  547. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  548. if(vecNormal.v[2]>=0){
  549. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  550. p[j]=Vector2Point2D(vecbuff[j]);
  551. }
  552. vecNormal=unitVector(vecNormal);
  553. colbuff=PhongModel(lightVector,vecNormal,viewVector,col);
  554. fillPolygon(p,obyek.fc[i].NumberofVertices,colbuff);
  555. }
  556. }
  557. }
  558.  
  559. void draw3Dc(object3D_t obyek,matrix3D_t mat){
  560. vector3D_t vec[1600], vecbuff[50];
  561. vector3D_t vecNormal;
  562. vector3D_t lightVector={0,0,1,1},viewVector={0,0,1,1};
  563. color_t colbuff;
  564. point2D_t p[50];
  565. int i,j;
  566. for(i=0;i<obyek.NumberofVertices;i++){
  567. vec[i]=Point2Vector(obyek.pnt[i]);
  568. vec[i]=mat*vec[i];
  569. }
  570. for(i=0;i<obyek.NumberofFaces;i++){
  571. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  572. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  573. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  574. if(vecNormal.v[2]<0){
  575. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  576. p[j]=Vector2Point2D(vecbuff[j]);
  577. }
  578. vecNormal=unitVector(vecNormal);
  579. colbuff=PhongModel(lightVector,vecNormal,viewVector,obyek.fc[i].col);
  580. fillPolygon(p,obyek.fc[i].NumberofVertices,colbuff);
  581. }
  582. }
  583. for(i=0;i<obyek.NumberofFaces;i++){
  584. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  585. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  586. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  587. if(vecNormal.v[2]>=0){
  588. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  589. p[j]=Vector2Point2D(vecbuff[j]);
  590. }
  591. vecNormal=unitVector(vecNormal);
  592. colbuff=PhongModel(lightVector,vecNormal,viewVector,obyek.fc[i].col);
  593. fillPolygon(p,obyek.fc[i].NumberofVertices,colbuff);
  594. }
  595. }
  596. }
  597.  
  598. void draw3Dcg(object3D_t obyek,matrix3D_t mat){
  599. vector3D_t vec[1600], vecbuff[50];
  600. vector3D_t vecNormal;
  601. vector3D_t lightVector={0,0,1,1},viewVector={0,0,1,1};
  602. color_t colbuff[50];
  603. point2D_t p[50];
  604. int i,j;
  605. for(i=0;i<obyek.NumberofVertices;i++){
  606. vec[i]=Point2Vector(obyek.pnt[i]);
  607. vec[i]=mat*vec[i];
  608. }
  609. for(i=0;i<obyek.NumberofFaces;i++){
  610. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  611. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  612. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  613. if(vecNormal.v[2]<0){
  614. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  615. p[j]=Vector2Point2D(vecbuff[j]);
  616. vecNormal=unitVector(vecbuff[j]);
  617. colbuff[j]=PhongModel(lightVector,vecNormal,viewVector,obyek.col[obyek.fc[i].pnt[j]]);
  618. }
  619. gradatePolygon(p,obyek.fc[i].NumberofVertices,colbuff);
  620. }
  621. }
  622. for(i=0;i<obyek.NumberofFaces;i++){
  623. for(j=0;j<obyek.fc[i].NumberofVertices;j++)
  624. vecbuff[j]=vec[obyek.fc[i].pnt[j]];
  625. vecNormal=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
  626. if(vecNormal.v[2]>=0){
  627. for(j=0;j<obyek.fc[i].NumberofVertices;j++){
  628. p[j]=Vector2Point2D(vecbuff[j]);
  629. vecNormal=unitVector(vecbuff[j]);
  630. colbuff[j]=PhongModel(lightVector,vecNormal,viewVector,obyek.col[obyek.fc[i].pnt[j]]);
  631. }
  632. gradatePolygon(p,obyek.fc[i].NumberofVertices,colbuff);
  633. }
  634. }
  635. }
  636.  
  637. void makeCube(object3D_t &kubus, float d){
  638. object3D_t obyek={8,
  639. {{0,0,0},{d,0,0},{d,0,d},{0,0,d},{0,d,0},{d,d,0},{d,d,d},{0,d,d}},
  640. {{1,1,0},{1,1,0},{1,1,0},{1,1,0},{1,1,0},{1,1,0},{1,1,0}},
  641. 6,
  642. {{4,{0,1,2,3},{1,1,0}},{4,{4,7,6,5},{1,1,0}},{4,{1,5,6,2},{1,1,0}},{4,{0,3,7,4},{1,1,0}},{4,{2,6,7,3},{1,1,0}},{4,{0,4,5,1},{1,1,0}}}};
  643. matrix3D_t mat=translationMTX(-d/2,-d/2,-d/2);
  644. vector3D_t vec;
  645. kubus=obyek;
  646. for(int i=0;i<kubus.NumberofVertices;i++){
  647. vec=Point2Vector(kubus.pnt[i]);
  648. vec=mat*vec;
  649. kubus.pnt[i]=Vector2Point3D(vec);
  650. }
  651. }
  652.  
  653. void makeCylinder(object3D_t &silinder, int n, float r, float h){
  654. float a=6.28/n;
  655. int i;
  656. for(i=0;i<n;i++){
  657. silinder.pnt[i].x=r*cos(i*a);
  658. silinder.pnt[i].y=0;
  659. silinder.pnt[i].z=r*sin(i*a);
  660. silinder.pnt[n+i].x=r*cos(i*a);
  661. silinder.pnt[n+i].y=h;
  662. silinder.pnt[n+i].z=r*sin(i*a);
  663. }
  664. silinder.NumberofVertices=2*n;
  665. for(i=0;i<n;i++){
  666. silinder.fc[i].NumberofVertices=4;
  667. silinder.fc[i].pnt[0]=i;
  668. silinder.fc[i].pnt[1]=n+i;
  669. silinder.fc[i].pnt[2]=n+i+1;
  670. silinder.fc[i].pnt[3]=i+1;
  671. if(i==(n-1)){
  672. silinder.fc[i].pnt[2]=n;
  673. silinder.fc[i].pnt[3]=0;
  674. }
  675. }
  676. silinder.fc[n].NumberofVertices=n;
  677. for(i=0;i<n;i++) silinder.fc[n].pnt[i]=i;
  678. silinder.fc[n+1].NumberofVertices=n;
  679. for(i=0;i<n;i++) silinder.fc[n+1].pnt[i]=2*n-1-i;
  680. silinder.NumberofFaces=n+2;
  681. color_t c={1,1,0};
  682. for(i=0;i<silinder.NumberofFaces;i++) silinder.fc[i].col=c;
  683. for(i=0;i<silinder.NumberofVertices;i++)
  684. silinder.col[i]=c;
  685. }
  686.  
  687. void makeCylinderAwur(object3D_t &silinder, int n, float r, float h){
  688. float a=6.28/n;
  689. int i;
  690. float f;
  691. for(i=0;i<n;i++){
  692. f=3*i/n;
  693. silinder.pnt[i].x=r*f*cos(i*a);
  694. silinder.pnt[i].y=0;
  695. silinder.pnt[i].z=r*f*sin(i*a);
  696. silinder.pnt[n+i].x=r*f*cos(i*a);
  697. silinder.pnt[n+i].y=h;
  698. silinder.pnt[n+i].z=r*f*sin(i*a);
  699. }
  700. silinder.NumberofVertices=2*n;
  701. for(i=0;i<n;i++){
  702. silinder.fc[i].NumberofVertices=4;
  703. silinder.fc[i].pnt[0]=i;
  704. silinder.fc[i].pnt[1]=n+i;
  705. silinder.fc[i].pnt[2]=n+i+1;
  706. silinder.fc[i].pnt[3]=i+1;
  707. if(i==(n-1)){
  708. silinder.fc[i].pnt[2]=n;
  709. silinder.fc[i].pnt[3]=0;
  710. }
  711. }
  712. silinder.fc[n].NumberofVertices=n;
  713. for(i=0;i<n;i++) silinder.fc[n].pnt[i]=i;
  714. silinder.fc[n+1].NumberofVertices=n;
  715. for(i=0;i<n;i++) silinder.fc[n+1].pnt[i]=2*n-1-i;
  716. silinder.NumberofFaces=n+2;
  717. color_t c={1,1,0};
  718. for(i=0;i<silinder.NumberofFaces;i++) silinder.fc[i].col=c;
  719. for(i=0;i<silinder.NumberofVertices;i++)
  720. silinder.col[i]=c;
  721. }
  722.  
  723. void makeCone(object3D_t &kerucut, int n, float r,float h){
  724. float a=6.28/n;
  725. int i;
  726. kerucut.pnt[0].x=0;
  727. kerucut.pnt[0].y=h;
  728. kerucut.pnt[0].z=0;
  729. for(i=1;i<=n;i++){
  730. kerucut.pnt[i].x=r*cos(i*a);
  731. kerucut.pnt[i].y=0;
  732. kerucut.pnt[i].z=r*sin(i*a);
  733. }
  734. for(i=0;i<n;i++){
  735. kerucut.fc[i].NumberofVertices=3;
  736. kerucut.fc[i].pnt[0]=0;
  737. kerucut.fc[i].pnt[1]=i+2;
  738. kerucut.fc[i].pnt[2]=i+1;
  739. if(i==(n-1)) kerucut.fc[i].pnt[1]=1;
  740. }
  741. kerucut.fc[n].NumberofVertices=n;
  742. for(i=0;i<n;i++) kerucut.fc[n].pnt[i]=i+1;
  743. kerucut.NumberofVertices=n+1;
  744. kerucut.NumberofFaces=n+1;
  745. color_t c={1,1,0};
  746. for(i=0;i<kerucut.NumberofFaces;i++) kerucut.fc[i].col=c;
  747. for(i=0;i<kerucut.NumberofVertices;i++)
  748. kerucut.col[i]=c;
  749. }
  750.  
  751. void makeCylinderN(object3D_t &silinder,int m,int n,float r[],float h[],int sw){
  752. float a=6.26/n;
  753. float b=0;
  754. int i,j;
  755. silinder.NumberofVertices=(m+1)*n;
  756. for(i=0;i<=m;i++){
  757. if(i>0) b=b+h[i-1];
  758. for(j=0;j<n;j++){
  759. silinder.pnt[i*n+j].x=r[i]*cos(j*a);
  760. silinder.pnt[i*n+j].y=b;
  761. silinder.pnt[i*n+j].z=r[i]*sin(j*a);
  762. }
  763. }
  764. silinder.NumberofFaces=m*n+2;
  765. for(i=0;i<m;i++){
  766. for(j=0;j<n;j++){
  767. silinder.fc[i*n+j].NumberofVertices=4;
  768. silinder.fc[i*n+j].pnt[0]=i*n+j;
  769. silinder.fc[i*n+j].pnt[1]=(i+1)*n+j;
  770. silinder.fc[i*n+j].pnt[2]=(i+1)*n+j+1;
  771. silinder.fc[i*n+j].pnt[3]=i*n+j+1;
  772. if(j==(n-1)){
  773. silinder.fc[i*n+j].pnt[2]=i*n+j+1;
  774. silinder.fc[i*n+j].pnt[3]=(i-1)*n+j+1;
  775. }
  776. }
  777. }
  778. if(sw==0 || sw==1){
  779. silinder.NumberofFaces = m*n+1;
  780. silinder.fc[m*n].NumberofVertices=n;
  781. for(i=0;i<n;i++) silinder.fc[m*n].pnt[i]=i;
  782. }
  783. if(sw==0 || sw==2){
  784. silinder.NumberofFaces = m*n+1;
  785. silinder.fc[m*n+1].NumberofVertices=n;
  786. for(i=0;i<n;i++) silinder.fc[m*n+1].pnt[i]=(m+1)*n-1-i;
  787. }
  788. color_t c={1,1,0};
  789. for(i=0;i<silinder.NumberofFaces;i++) silinder.fc[i].col=c;
  790. for(i=0;i<silinder.NumberofVertices;i++)
  791. silinder.col[i]=c;
  792. }
  793.  
  794. void makeSphere(object3D_t &sphere,int n,float r){
  795. float a=6.28/n;
  796. float b=6.28/n;
  797. int i,j;
  798. sphere.NumberofVertices=(n+1)*n;
  799. for(i=0;i<=n;i++){
  800. for(j=0;j<n;j++){
  801. sphere.pnt[i*n+j].x=r*cos(j*a)*sin(i*b);
  802. sphere.pnt[i*n+j].y=r*cos(i*b);
  803. sphere.pnt[i*n+j].z=r*sin(j*a)*sin(i*b);
  804. }
  805. }
  806. sphere.NumberofFaces=n*n+2;
  807. for(i=0;i<n;i++){
  808. for(j=0;j<n;j++){
  809. sphere.fc[i*n+j].NumberofVertices=4;
  810. sphere.fc[i*n+j].pnt[0]=i*n+j;
  811. sphere.fc[i*n+j].pnt[1]=(i+1)*n+j;
  812. sphere.fc[i*n+j].pnt[2]=(i+1)*n+j+1;
  813. sphere.fc[i*n+j].pnt[3]=i*n+j+1;
  814. if(j==(n-1)){
  815. sphere.fc[i*n+j].pnt[2]=i*n+j+1;
  816. sphere.fc[i*n+j].pnt[3]=(i-1)*n+j+1;
  817. }
  818. }
  819. }
  820. sphere.fc[n*n].NumberofVertices=n;
  821. for(i=0;i<n;i++) sphere.fc[n*n].pnt[i]=i;
  822. sphere.fc[n*n+1].NumberofVertices=n;
  823. for(i=0;i<n;i++) sphere.fc[n*n+1].pnt[i]=(n+1)*n-1-i;
  824. color_t c={1,1,0};
  825. for(i=0;i<sphere.NumberofFaces;i++) sphere.fc[i].col=c;
  826. for(i=0;i<sphere.NumberofVertices;i++)
  827. sphere.col[i]=c;
  828. }
  829.  
  830. void makeApple(object3D_t &sphere,int n,float r){
  831. float a=6.28/n;
  832. float b=6.28/n;
  833. int i,j,k;
  834. sphere.NumberofVertices=(n+1)*n;
  835. for(i=0;i<=n;i++){
  836. for(j=0;j<n;j++){
  837. sphere.pnt[i*n+j].x=r*cos(j*a)*sin(i*b);
  838. sphere.pnt[i*n+j].y=r*cos(i*b);
  839. if(i>n-1){
  840. k=i-(n-1);
  841. sphere.pnt[i*n+j].y-=20*k;
  842. }
  843. sphere.pnt[i*n+j].z=r*sin(j*a)*sin(i*b);
  844. }
  845. }
  846. sphere.NumberofFaces=n*n+2;
  847. for(i=0;i<n;i++){
  848. for(j=0;j<n;j++){
  849. sphere.fc[i*n+j].NumberofVertices=4;
  850. sphere.fc[i*n+j].pnt[0]=i*n+j;
  851. sphere.fc[i*n+j].pnt[1]=(i+1)*n+j;
  852. sphere.fc[i*n+j].pnt[2]=(i+1)*n+j+1;
  853. sphere.fc[i*n+j].pnt[3]=i*n+j+1;
  854. if(j==(n-1)){
  855. sphere.fc[i*n+j].pnt[2]=i*n+j+1;
  856. sphere.fc[i*n+j].pnt[3]=(i-1)*n+j+1;
  857. }
  858. }
  859. }
  860. sphere.fc[n*n].NumberofVertices=n;
  861. for(i=0;i<n;i++) sphere.fc[n*n].pnt[i]=i;
  862. sphere.fc[n*n+1].NumberofVertices=n;
  863. for(i=0;i<n;i++) sphere.fc[n*n+1].pnt[i]=(n+1)*n-1-i;
  864. color_t c={1,1,0};
  865. for(i=0;i<sphere.NumberofFaces;i++) sphere.fc[i].col=c;
  866. for(i=0;i<sphere.NumberofVertices;i++)
  867. sphere.col[i]=c;
  868. }
  869.  
  870. void makeCheese(object3D_t &o,int n,float d){
  871. o.NumberofVertices=(n+1)*(n+1);
  872. int i,j,k;
  873. for(i=0;i<n+1;i++)
  874. for(j=0;j<n+1;j++){
  875. k=(n+1)*i+j;
  876. o.pnt[k].x=j*d;
  877. o.pnt[k].y=0;
  878. o.pnt[k].z=i*d;
  879. }
  880. o.NumberofFaces = n*n;
  881. color_t w1={1,1,1},w2={0,0,0};
  882. for(i=0;i<n;i++)
  883. for(j=0;j<n;j++){
  884. k=n*i+j;
  885. o.fc[k].NumberofVertices=4;
  886. o.fc[k].pnt[0]=(n+1)*i+j;
  887. o.fc[k].pnt[1]=(n+1)*i+j+n+1;
  888. o.fc[k].pnt[2]=(n+1)*i+j+n+2;
  889. o.fc[k].pnt[3]=(n+1)*i+j+1;
  890. if((i+j)%2==0) o.fc[k].col=w1;
  891. else o.fc[k].col=w2;
  892. }
  893. for(i=0;i<o.NumberofVertices;i++)
  894. o.col[i]=w1;
  895. }
  896.  
  897. point3D_t interpolate(point3D_t p1,point3D_t p2,float a){
  898. point3D_t p;
  899. p.x=(1-a)*p1.x+a*p2.x;
  900. p.y=(1-a)*p1.y+a*p2.y;
  901. p.z=(1-a)*p1.z+a*p2.z;
  902. return p;
  903. }
  904.  
  905. void userdraw(void)
  906. {
  907. setColor(1,0,0);
  908.  
  909.  
  910. object3D_t kubus = {
  911. 8,
  912. {{0,0,0}, {100,0,0}, {100,0,100}, {0,0,100}, {0,100,0}, {100,100,0}, {100,100,100}, {0,100,100}},
  913. {{1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}},
  914. 6,
  915. {
  916. {4, {0,1,2,3}, {1,1,1}},
  917. {4, {7,6,5,4}, {1,1,1}},
  918. {4, {6,7,3,2}, {1,1,1}},
  919. {4, {4,5,1,0}, {1,1,1}},
  920. {4, {0,3,7,4}, {1,1,1}},
  921. {4, {2,1,5,6}, {1,1,1}}
  922. }
  923. };
  924.  
  925. object3D_t prismaSegitiga = {
  926. 6,
  927. {{0,0,0}, {50,0,0}, {50,0,100}, {0,0,100}, {0,50,0}, {0,50,100}},
  928. {{1,0.7,0}, {0,0.7,1}, {0,0.7,1}, {1,0.7,0}, {0,0.7,0}, {0,0.7,0}},
  929. 5,
  930. {
  931. {4, {0,1,2,3}, {1,1,1}},
  932. {3, {0,4,1}, {1,1,1}},
  933. {4, {0,3,5,4}, {1,1,1}},
  934. {4, {5,2,1,4}, {1,1,1}},
  935. {3, {5,3,2}, {1,1,1}}
  936. }
  937. };
  938. object3D_t limasSegitiga = {
  939. 4,
  940. {{0,0,0}, {50,0,100}, {0,0,100}, {0,50,100}},
  941. {{1,0,0}, {0,0,1}, {1,0,0}, {0,1,0}},
  942. 4,
  943. {
  944. {3, {0,1,2}, {1,1,1}},
  945. {3, {0,2,3}, {1,1,1}},
  946. {3, {3,1,0}, {1,1,1}},
  947. {3, {3,2,1}, {1,1,1}},
  948. }
  949. };
  950. /*object3D_t kerucut;
  951. makeCone(kerucut, 10, 25, 80);
  952. matrix3D_t mat1 = tilting * translationMTX(0,100,0);
  953. color_t w1 = {0.9,0.8,0.4};
  954.  
  955. object3D_t silinder;
  956. makeCylinder(silinder, 10, 25, 200);
  957. matrix3D_t mat2 = tilting * translationMTX(0,-100,0);
  958. color_t w2 = {0,0.6,0.8};
  959.  
  960. object3D_t silinder1;
  961. makeCylinder(silinder1, 10, 25, 10);
  962. matrix3D_t mat3 = tilting * translationMTX(0,-110,0);
  963. color_t w3 = {1,1,1};
  964.  
  965. object3D_t silinder2;
  966. makeCylinder(silinder2, 10, 25, 20);
  967. matrix3D_t mat4 = tilting * translationMTX(0,-130,0);
  968. color_t w4 = {1,0,0};
  969.  
  970. draw3Dw(silinder2, mat4, w4);
  971. draw3Dw(silinder1, mat3, w3);
  972. draw3Dw(silinder, mat2, w2);
  973. draw3Dw(kerucut, mat1, w1);
  974. */
  975.  
  976.  
  977.  
  978. /*
  979. //Membuat Bola
  980. point3D_t lingkaran[30];
  981. point2D_t p[30];
  982. float a;
  983. float b;
  984. for(b=0;b<3.14;b+=0.2){
  985. for(int i=0;i<30;i++){
  986. a=i*12/57.4;
  987. lingkaran[i].x=100*cos(a);
  988. lingkaran[i].z=100*sin(a);
  989. lingkaran[i].y=0;
  990. }
  991. matrix3D_t met = tilt*rotationZMTX(b);
  992. vector3D_t vec;
  993. for(int i=0;i<30;i++){
  994. vec=Point2Vector(lingkaran[i]);
  995. vec=met*vec;
  996. p[i]=Vector2Point2D(vec);
  997. }
  998. setColor(1,1,1);
  999. drawPolygon(p,30);
  1000. d+=0.0001;
  1001. } */
  1002.  
  1003. /*static float d=0;
  1004. matrix3D_t tilt=rotationXMTX(0.5)*rotationYMTX(d);
  1005. setColor(0,1,0);
  1006.  
  1007. float z[3];
  1008. object3D_t obj[3];
  1009. matrix3D_t mat[3];
  1010.  
  1011. makeSphere(obj[0],20,80);
  1012. makeSphere(obj[1],20,50);
  1013. makeSphere(obj[2],20,25);
  1014.  
  1015. color_t w[3]={{1,1,0},{0,1,0},{1,0,0}};
  1016.  
  1017. mat[0] = tilt;
  1018. mat[1] = mat[0]*translationMTX(250,0,0);
  1019. mat[2] = mat[1]*rotationYMTX(2*d)*
  1020. translationMTX(150,0,0);
  1021.  
  1022. //menghitung rata dari titik Z
  1023. z[0]=zRata(obj[0],mat[0]);
  1024. z[1]=zRata(obj[1],mat[1]);
  1025. z[2]=zRata(obj[2],mat[2]);
  1026.  
  1027. float zt;
  1028. object3D_t objt;
  1029. matrix3D_t matt;
  1030. color_t wt;
  1031. for(int i=0;i<2;i++)
  1032. for(int j=0;j<2;j++){
  1033. if(z[j]>z[j+1]){
  1034. objt=obj[j]; zt=z[j]; matt=mat[j];
  1035. obj[j]=obj[j+1]; z[j]=z[j+1]; mat[j]=mat[j+1];
  1036. obj[j+1]=objt; z[j+1]=zt; mat[j+1]=matt;
  1037. wt=w[j]; w[j]=w[j+1]; w[j+1]=wt;
  1038. }
  1039. }
  1040. for(int i=0;i<3;i++){
  1041. draw3Dw(obj[i],mat[i],w[i]);
  1042. }
  1043. d+=0.001;
  1044. */
  1045.  
  1046.  
  1047. static float d=0;
  1048. matrix3D_t tilt=rotationXMTX(0.4)*rotationYMTX(d);
  1049.  
  1050. object3D_t obj[3];
  1051. float z[3];
  1052.  
  1053.  
  1054. float h[15]={20,30,3,5,3,90,3,5,3,30,30,20,3,12,3};
  1055. float r[16]={30,40,40,30,30,40,40,30,30,40,40,16,16,20,20,15};
  1056.  
  1057. float h1[99] = {5, 10, 15, 50, 10, 10, 30};
  1058. float r1[99] = {40, 40, 10, 5, 5, 10, 25, 70};
  1059.  
  1060. float h2[99] = {5, 20};
  1061. float r2[99] = {60, 60, 100};
  1062.  
  1063. color_t w3 = {1, 1, 0};
  1064. matrix3D_t mat[3];
  1065.  
  1066. makeCylinderN(obj[0], 15,40,r,h,0);
  1067. makeCylinderN(obj[1], 7, 30, r1, h1, 1);
  1068. makeCylinderN(obj[2], 2, 20, r2, h2, 1);
  1069.  
  1070. color_t w[3]={{0,1,1},{1,0.5,1},{1,1,0}};
  1071.  
  1072. mat[2] = tilt*translationMTX(150,-150,0);
  1073. mat[0] = tilt*translationMTX(0,-150,0);
  1074. mat[1] = tilt*translationMTX(-150,-150,0);
  1075.  
  1076. z[0]=zRata(obj[0],mat[0]);
  1077. z[1]=zRata(obj[1],mat[1]);
  1078. z[2]=zRata(obj[2],mat[2]);
  1079.  
  1080. float zt;
  1081. object3D_t objt;
  1082. matrix3D_t matt;
  1083. color_t wt;
  1084. for(int i=0;i<2;i++)
  1085. for(int j=0;j<2;j++){
  1086. if(z[j]>z[j+1]){
  1087. objt=obj[j]; zt=z[j]; matt=mat[j];
  1088. obj[j]=obj[j+1]; z[j]=z[j+1]; mat[j]=mat[j+1];
  1089. obj[j+1]=objt; z[j+1]=zt; mat[j+1]=matt;
  1090. wt=w[j]; w[j]=w[j+1]; w[j+1]=wt;
  1091. }
  1092. }
  1093. for(int i=0;i<3;i++){
  1094. draw3Dw(obj[i],mat[i],w[i]);
  1095. }
  1096. d+=0.001;
  1097.  
  1098. }
  1099.  
  1100. void awal(){
  1101. static float a = 0;
  1102. setColor(1,1,1);
  1103. matrix3D_t tilting=rotationYMTX(a) * rotationXMTX(0.5);
  1104. drawAxes(tilting);
  1105. point3D_t p = {100,100,50};
  1106. vector3D_t vec;
  1107. point2D_t p2;
  1108. vec = Point2Vector(p);
  1109. vec = tilting * vec;
  1110. p2 = Vector2Point2D(vec);
  1111. glPointSize(4);
  1112. glBegin(GL_POINTS);
  1113. glVertex2f(p2.x, p2.y);
  1114. glEnd();
  1115.  
  1116. point3D_t q[2] = {
  1117. {100, 0, 0}, {0, 100, 0}
  1118. };
  1119. point2D_t q2[2];
  1120. for(int i = 0 ; i < 2 ; i++) {
  1121. vec = Point2Vector(q[i]);
  1122. vec = tilting * vec;
  1123. q2[i] = Vector2Point2D(vec);
  1124. }
  1125. setColor(1,0,0);
  1126. drawLine(q2[0], q2[1]);
  1127. a += 0.001;
  1128.  
  1129. point3D_t r[3] = {
  1130. {0, 0, 0}, {-100, 0, 0}, {0, -100, 0}
  1131. };
  1132. point2D_t r2[3];
  1133. for(int i = 0 ; i < 3 ; i++) {
  1134. vec = Point2Vector(r[i]);
  1135. vec = tilting * vec;
  1136. r2[i] = Vector2Point2D(vec);
  1137. }
  1138. setColor(0, 0, 1);
  1139. glBegin(GL_TRIANGLES);
  1140. glVertex2f(r2[0].x, r2[0].y);
  1141. glVertex2f(r2[1].x, r2[1].y);
  1142. glVertex2f(r2[2].x, r2[2].y);
  1143. glEnd();
  1144.  
  1145. object3D_t obj;
  1146. makeCube(obj, 50);
  1147. draw3D(obj, tilting);
  1148. }
  1149.  
  1150. int main(int argc, char **argv)
  1151. {
  1152. glutInit(&argc,argv);
  1153. glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
  1154. glutInitWindowPosition(100,100);
  1155. glutInitWindowSize(640,480);
  1156. glutCreateWindow ("cube");
  1157. glClearColor(0.0, 0.0, 0.0, 0.0);
  1158. gluOrtho2D(-320., 320., -240.0, 240.0);
  1159. // Define the dimensions of the Orthographic Viewing Volume
  1160. glutIdleFunc(display); // idle event call back
  1161. glutDisplayFunc(display);
  1162. glutMainLoop();
  1163. return 0;
  1164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement