Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. #include <time.h>
  6.  
  7.  
  8. #ifdef _APPLE_
  9. #include <GLUT/glut.h>
  10. #else
  11. #include <GL/glut.h>
  12. #endif
  13.  
  14.  
  15. #ifndef M_PI
  16. #define M_PI 3.1415926535897932384626433832795
  17. #endif
  18.  
  19. #define RAD(x) (M_PI*(x)/180)
  20. #define GRAUS(x) (180*(x)/M_PI)
  21.  
  22. #define DEBUG 1
  23.  
  24. #define DELAY_MOVIMENTO 20
  25. #define RAIO_ROTACAO 20
  26.  
  27. #define LARGURA_BASE 4
  28. #define COMPRIMENTO_BASE 7
  29. #define ALTURA_BASE 1
  30.  
  31. #define LARGURA_TORRE 2
  32. #define COMPRIMENTO_TORRE 2
  33. #define ALTURA_TORRE 0.5
  34.  
  35. #define COMPRIMENTO_CANHAO 4
  36. #define RAIO_CANHAO 0.2
  37.  
  38.  
  39.  
  40. /* VARIAVEIS GLOBAIS */
  41.  
  42. typedef struct {
  43. GLboolean q, a, z, x, up, down, left, right;
  44. }Teclas;
  45.  
  46. typedef struct {
  47. GLfloat x, y, z;
  48. }Pos;
  49.  
  50. typedef struct {
  51. Pos eye, center, up;
  52. GLfloat fov;
  53. }Camera;
  54.  
  55.  
  56. typedef struct {
  57. GLboolean doubleBuffer;
  58. GLint delayMovimento;
  59. Teclas teclas;
  60. GLuint menu_id;
  61. GLboolean menuActivo;
  62. Camera camera;
  63. GLboolean debug;
  64. GLboolean ortho;
  65. }Estado;
  66.  
  67. typedef struct {
  68. GLfloat x, y;
  69. GLint pontuacao;
  70. }Raquete;
  71.  
  72. typedef struct {
  73. GLfloat x, y;
  74. GLfloat velocidade;
  75. GLfloat direccao;
  76. GLfloat direccaoRodas;
  77. GLfloat angTorre;
  78. GLfloat angCanhao;
  79. }Tanque;
  80.  
  81. typedef struct {
  82. Tanque tanque;
  83. GLboolean parado;
  84. }Modelo;
  85.  
  86.  
  87. Estado estado;
  88. Modelo modelo;
  89.  
  90. void inicia_modelo()
  91. {
  92. modelo.tanque.x = 0;
  93. modelo.tanque.y = -20;
  94. modelo.tanque.velocidade = 0;
  95. modelo.tanque.direccao = 0;
  96. modelo.tanque.direccaoRodas = 0;
  97. modelo.tanque.angTorre = 0;
  98. modelo.tanque.angCanhao = 0;
  99.  
  100. }
  101.  
  102. /* Inicialização do ambiente OPENGL */
  103. void Init(void)
  104. {
  105.  
  106. srand((unsigned)time(NULL));
  107.  
  108. modelo.parado = GL_FALSE;
  109.  
  110. estado.debug = DEBUG;
  111. estado.menuActivo = GL_FALSE;
  112. estado.delayMovimento = DELAY_MOVIMENTO;
  113. estado.camera.eye.x = 40;
  114. estado.camera.eye.y = 40;
  115. estado.camera.eye.z = 40;
  116. estado.camera.center.x = 0;
  117. estado.camera.center.y = 0;
  118. estado.camera.center.z = 0;
  119. estado.camera.up.x = 0;
  120. estado.camera.up.y = 0;
  121. estado.camera.up.z = 1;
  122. estado.ortho = GL_TRUE;
  123. estado.camera.fov = 60;
  124.  
  125. estado.teclas.a = estado.teclas.q = estado.teclas.z = estado.teclas.x = \
  126. estado.teclas.up = estado.teclas.down = estado.teclas.left = estado.teclas.right = GL_FALSE;
  127.  
  128. inicia_modelo();
  129.  
  130. glClearColor(0.0, 0.0, 0.0, 0.0);
  131.  
  132. glEnable(GL_POINT_SMOOTH);
  133. glEnable(GL_LINE_SMOOTH);
  134. glEnable(GL_POLYGON_SMOOTH);
  135. glEnable(GL_DEPTH_TEST);
  136. //glutIgnoreKeyRepeat(GL_TRUE);
  137.  
  138. }
  139.  
  140. /**************************************
  141. * callbacks de janela/desenho *
  142. **************************************/
  143.  
  144. // CALLBACK PARA REDIMENSIONAR JANELA
  145.  
  146. void Reshape(int width, int height)
  147. {
  148. // glViewport(botom, left, width, height)
  149. // define parte da janela a ser utilizada pelo OpenGL
  150.  
  151. glViewport(0, 0, (GLint)width, (GLint)height);
  152.  
  153.  
  154. // Matriz Projeccao
  155. // Matriz onde se define como o mundo e apresentado na janela
  156. glMatrixMode(GL_PROJECTION);
  157. glLoadIdentity();
  158.  
  159. // gluOrtho2D(left,right,bottom,top);
  160. // projeccao ortogonal 2D, com profundidade (Z) entre -1 e 1
  161. if (estado.debug)
  162. printf("Reshape %s\n", (estado.ortho) ? "ORTHO" : "PERSPECTIVE");
  163.  
  164. if (estado.ortho)
  165. {
  166. if (width < height)
  167. glOrtho(-20, 20, -20 * (GLdouble)height / width, 20 * (GLdouble)height / width, -100, 100);
  168. else
  169. glOrtho(-20 * (GLdouble)width / height, 20 * (GLdouble)width / height, -20, 20, -100, 100);
  170. }
  171. else
  172. gluPerspective(estado.camera.fov, (GLfloat)width / height, 1, 100);
  173.  
  174. // Matriz Modelview
  175. // Matriz onde são realizadas as tranformacoes dos modelos desenhados
  176. glMatrixMode(GL_MODELVIEW);
  177. }
  178.  
  179.  
  180. void desenhaPoligono(GLfloat a[], GLfloat b[], GLfloat c[], GLfloat d[], GLfloat cor[])
  181. {
  182.  
  183. glBegin(GL_POLYGON);
  184. glColor3fv(cor);
  185. glVertex3fv(a);
  186. glVertex3fv(b);
  187. glVertex3fv(c);
  188. glVertex3fv(d);
  189. glEnd();
  190. }
  191.  
  192.  
  193. void desenhaCubo()
  194. {
  195. GLfloat vertices[][3] = { {-0.5,-0.5,-0.5},
  196. {0.5,-0.5,-0.5},
  197. {0.5,0.5,-0.5},
  198. {-0.5,0.5,-0.5},
  199. {-0.5,-0.5,0.5},
  200. {0.5,-0.5,0.5},
  201. {0.5,0.5,0.5},
  202. {-0.5,0.5,0.5} };
  203.  
  204. GLfloat cores[][3] = { {0.0,1.0,1.0},
  205. {1.0,0.0,0.0},
  206. {1.0,1.0,0.0},
  207. {0.0,1.0,0.0},
  208. {1.0,0.0,1.0},
  209. {0.0,0.0,1.0},
  210. {1.0,1.0,1.0} };
  211.  
  212. desenhaPoligono(vertices[1], vertices[0], vertices[3], vertices[2], cores[0]);
  213. desenhaPoligono(vertices[2], vertices[3], vertices[7], vertices[6], cores[1]);
  214. desenhaPoligono(vertices[3], vertices[0], vertices[4], vertices[7], cores[2]);
  215. desenhaPoligono(vertices[6], vertices[5], vertices[1], vertices[2], cores[3]);
  216. desenhaPoligono(vertices[4], vertices[5], vertices[6], vertices[7], cores[4]);
  217. desenhaPoligono(vertices[5], vertices[4], vertices[0], vertices[1], cores[5]);
  218. }
  219.  
  220.  
  221. void strokeString(char* str, double x, double y, double z, double s)
  222. {
  223. int i, n;
  224.  
  225. n = strlen(str);
  226. glPushMatrix();
  227. glColor3d(0.0, 0.0, 0.0);
  228. glTranslated(x, y, z);
  229. glScaled(s, s, s);
  230. for (i = 0; i < n; i++)
  231. glutStrokeCharacter(GLUT_STROKE_ROMAN, (int)str[i]);
  232.  
  233. glPopMatrix();
  234.  
  235. }
  236.  
  237. void bitmapString(char* str, double x, double y)
  238. {
  239. int i, n;
  240.  
  241. // fonte pode ser:
  242. // GLUT_BITMAP_8_BY_13
  243. // GLUT_BITMAP_9_BY_15
  244. // GLUT_BITMAP_TIMES_ROMAN_10
  245. // GLUT_BITMAP_TIMES_ROMAN_24
  246. // GLUT_BITMAP_HELVETICA_10
  247. // GLUT_BITMAP_HELVETICA_12
  248. // GLUT_BITMAP_HELVETICA_18
  249. //
  250. // int glutBitmapWidth ( void *font , int character);
  251. // devolve a largura de um carácter
  252. //
  253. // int glutBitmapLength ( void *font , const unsigned char *string );
  254. // devolve a largura de uma string (soma da largura de todos os caracteres)
  255.  
  256. n = strlen(str);
  257. glRasterPos2d(x, y);
  258. for (i = 0; i < n; i++)
  259. glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)str[i]);
  260. }
  261.  
  262. void bitmapCenterString(char* str, double x, double y)
  263. {
  264. int i, n;
  265.  
  266. n = strlen(str);
  267. glRasterPos2d(x - glutBitmapLength(GLUT_BITMAP_HELVETICA_18, (const unsigned char*)str) * 0.5, y);
  268. for (i = 0; i < n; i++)
  269. glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, (int)str[i]);
  270. }
  271.  
  272.  
  273. // ... definicao das rotinas auxiliares de desenho ...
  274.  
  275.  
  276. void desenhaTanque(Tanque t)
  277. {
  278. glPushMatrix();
  279. glTranslatef(0, 0, ALTURA_BASE);
  280. glPushMatrix();
  281. glScalef(COMPRIMENTO_BASE, LARGURA_BASE, ALTURA_BASE);
  282. desenhaCubo();
  283. glPopMatrix();
  284.  
  285.  
  286. glColor3f(1.0, 1.0, 1.0);
  287.  
  288. GLUquadric* quad;
  289. quad = gluNewQuadric();
  290.  
  291. //front left
  292. glPushMatrix();
  293. glTranslatef(COMPRIMENTO_BASE * 0.4, LARGURA_BASE*0.6,- ALTURA_BASE*0.5);
  294. glRotatef(90,1,modelo.tanque.direccaoRodas,0);
  295. gluCylinder(quad,0.5,0.5,0.4,10,2);
  296. glPopMatrix();
  297.  
  298. //rear left
  299. glPushMatrix();
  300. glTranslatef(-COMPRIMENTO_BASE * 0.4, LARGURA_BASE * 0.6, -ALTURA_BASE * 0.5);
  301. glRotatef(90, 1, 0, 0);
  302. gluCylinder(quad, 0.5, 0.5, 0.4, 10, 2);
  303. glPopMatrix();
  304.  
  305. //front right
  306.  
  307. glPushMatrix();
  308. glTranslatef(COMPRIMENTO_BASE * 0.4, -LARGURA_BASE * 0.5, -ALTURA_BASE * 0.5);
  309. glRotatef(90, 1, modelo.tanque.direccaoRodas, 0);
  310. gluCylinder(quad, 0.5, 0.5, 0.4, 10, 2);
  311. glPopMatrix();
  312.  
  313. //rear right
  314.  
  315. glPushMatrix();
  316. glTranslatef(-COMPRIMENTO_BASE * 0.4, -LARGURA_BASE * 0.5, -ALTURA_BASE * 0.5);
  317. glRotatef(90, 1, 0, 0);
  318. gluCylinder(quad, 0.5, 0.5, 0.4, 10, 2);
  319. glPopMatrix();
  320.  
  321.  
  322.  
  323.  
  324. glTranslatef(0, 0, ALTURA_BASE * 0.5 + ALTURA_TORRE * 0.5);
  325. glRotatef(t.angTorre, 0, 0, 1);
  326. glPushMatrix();
  327. glScalef(COMPRIMENTO_TORRE, LARGURA_TORRE, ALTURA_TORRE);
  328. desenhaCubo();
  329. glPopMatrix();
  330.  
  331. //glTranslatef(COMPRIMENTO_TORRE * 0.5,0, 0);
  332. glRotatef(-t.angCanhao, 0, 1, 0);
  333. glTranslatef(COMPRIMENTO_CANHAO * 0.5, 0, 0);
  334. glPushMatrix();
  335. glScalef(COMPRIMENTO_CANHAO, RAIO_CANHAO * 2, RAIO_CANHAO * 2);
  336. desenhaCubo();
  337. glPopMatrix();
  338.  
  339. glPopMatrix();
  340.  
  341. }
  342.  
  343. void desenhaChao(GLfloat dimensao)
  344. {
  345.  
  346. glBegin(GL_POLYGON);
  347. glVertex3f(dimensao, dimensao, 0);
  348. glVertex3f(-dimensao, dimensao, 0);
  349. glVertex3f(-dimensao, -dimensao, 0);
  350. glVertex3f(dimensao, -dimensao, 0);
  351. glEnd();
  352.  
  353. }
  354.  
  355. // Callback de desenho
  356.  
  357. void Draw(void)
  358. {
  359. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  360.  
  361. glLoadIdentity();
  362.  
  363. gluLookAt(estado.camera.eye.x, estado.camera.eye.y, estado.camera.eye.z, \
  364. estado.camera.center.x, estado.camera.center.y, estado.camera.center.z, \
  365. estado.camera.up.x, estado.camera.up.y, estado.camera.up.z);
  366.  
  367. // ... chamada das rotinas auxiliares de desenho ...
  368.  
  369. /*gluLookAt(modelo.tanque.x, modelo.tanque.y, estado.camera.eye.z, \
  370. estado.camera.center.x, estado.camera.center.y, estado.camera.center.z, \
  371. estado.camera.up.x, estado.camera.up.y, estado.camera.up.z);
  372. */
  373.  
  374.  
  375.  
  376. glColor3f(0.5f, 0.5f, 0.5f);
  377. desenhaChao(RAIO_ROTACAO + 5);
  378.  
  379.  
  380. glPushMatrix();
  381. glTranslatef(modelo.tanque.x, modelo.tanque.y, 0);
  382. glRotatef(modelo.tanque.direccao, 0, 0, 1);
  383.  
  384. desenhaTanque(modelo.tanque);
  385.  
  386.  
  387. glPopMatrix();
  388.  
  389.  
  390. glFlush();
  391. if (estado.doubleBuffer)
  392. glutSwapBuffers();
  393. }
  394.  
  395. /*******************************
  396. * callbacks timer/idle *
  397. *******************************/
  398.  
  399. void Timer(int value)
  400. {
  401. glutTimerFunc(estado.delayMovimento, Timer, 0);
  402. if (estado.teclas.z)
  403. {
  404. modelo.tanque.angTorre += 2;
  405. }
  406. if (estado.teclas.x)
  407. {
  408. modelo.tanque.angTorre -= 2;
  409. }
  410. if (estado.teclas.q && modelo.tanque.angCanhao < 75)
  411. {
  412. modelo.tanque.angCanhao += 2;
  413. }
  414. if (estado.teclas.a && modelo.tanque.angCanhao > 0)
  415. {
  416. modelo.tanque.angCanhao -= 2;
  417. }
  418. if (estado.teclas.up && modelo.tanque.velocidade<1)
  419. {
  420. modelo.tanque.velocidade += 0.25;
  421. }
  422. if (estado.teclas.down && modelo.tanque.velocidade >-1)
  423. {
  424. modelo.tanque.velocidade -= 0.25;
  425. }
  426. if (estado.teclas.left && modelo.tanque.direccaoRodas < 2)
  427. {
  428. modelo.tanque.direccaoRodas +=0.5 ;
  429. }
  430. if (estado.teclas.right && modelo.tanque.direccaoRodas>-2)
  431. {
  432. modelo.tanque.direccaoRodas -= 0.5;
  433. }
  434. if (!estado.teclas.left && modelo.tanque.direccaoRodas > 0)
  435. {
  436. modelo.tanque.direccaoRodas -= 0.5;
  437. }
  438. if (!estado.teclas.right && modelo.tanque.direccaoRodas < 0)
  439. {
  440. modelo.tanque.direccaoRodas += 0.5;
  441. }
  442.  
  443.  
  444.  
  445.  
  446. if (modelo.tanque.velocidade > 0)
  447. {
  448. if (!estado.teclas.up)
  449. {
  450. modelo.tanque.velocidade -= 0.25;
  451. }
  452.  
  453. }
  454. else {
  455. if (modelo.tanque.velocidade <0)
  456. {
  457. if (!estado.teclas.down)
  458. {
  459. modelo.tanque.velocidade += 0.25;
  460. }
  461.  
  462. }
  463. }
  464.  
  465.  
  466.  
  467.  
  468.  
  469. //modelo.tanque.direccao = modelo.tanque.velocidade * cos(modelo.tanque.direccaoRodas);
  470.  
  471. modelo.tanque.x += modelo.tanque.velocidade * cos(RAD(modelo.tanque.direccao));
  472. modelo.tanque.y += modelo.tanque.velocidade * sin(RAD(modelo.tanque.direccao));
  473. modelo.tanque.direccao += modelo.tanque.velocidade * modelo.tanque.direccaoRodas;
  474.  
  475.  
  476. if (estado.menuActivo || modelo.parado) // sair em caso de o jogo estar parado ou menu estar activo
  477. {
  478. glutPostRedisplay();
  479. return;
  480. }
  481.  
  482.  
  483.  
  484. if (estado.menuActivo || modelo.parado) // sair em caso de o jogo estar parado ou menu estar activo
  485. return;
  486.  
  487. // redesenhar o ecra
  488. glutPostRedisplay();
  489. }
  490.  
  491.  
  492.  
  493. void imprime_ajuda(void)
  494. {
  495. printf("\n\nDesenho de um quadrado\n");
  496. printf("h,H - Ajuda \n");
  497. printf("z,Z - Roda torre para a esquerda\n");
  498. printf("x,X - Roda torre para a direita\n");
  499. printf("q,Q - Levantar canhao\n");
  500. printf("a,A - Baixar canhao\n");
  501. printf("i,I - Reinicia modelo\n");
  502. printf("o,O - Alterna entre projecãoo Ortografica e Perspectiva\n");
  503. printf("f,F - Poligono Fill \n");
  504. printf("l,L - Poligono Line \n");
  505. printf("p,P - Poligono Point \n");
  506. printf("s,S - Inicia/para movimento\n");
  507. printf("ESC - Sair\n");
  508. }
  509.  
  510. /*******************************
  511. * callbacks de teclado *
  512. *******************************/
  513.  
  514. // Callback para interaccao via teclado (carregar na tecla)
  515.  
  516. void Key(unsigned char key, int x, int y)
  517. {
  518. switch (key) {
  519.  
  520. case 27:
  521. exit(0);
  522. // ... accoes sobre outras teclas ...
  523.  
  524. case 'h':
  525. case 'H':
  526. imprime_ajuda();
  527. break;
  528. case 'i':
  529. case 'I':
  530. inicia_modelo();
  531. break;
  532. case 'o':
  533. case 'O':
  534. estado.ortho = !estado.ortho;
  535. Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  536. break;
  537. case 'Q':
  538. case 'q': estado.teclas.q = GL_TRUE;
  539. break;
  540. case 'A':
  541. case 'a': estado.teclas.a = GL_TRUE;
  542. break;
  543. case 'Z':
  544. case 'z': estado.teclas.z = GL_TRUE;
  545. break;
  546. case 'X':
  547. case 'x': estado.teclas.x = GL_TRUE;
  548. break;
  549. case 'D':
  550. case 'd': estado.debug = !estado.debug;
  551. if (estado.menuActivo || modelo.parado)
  552. glutPostRedisplay();
  553. printf("DEBUG is %s\n", (estado.debug) ? "ON" : "OFF");
  554. break;
  555. case 'f':
  556. case 'F':
  557. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  558. break;
  559. case 'p':
  560. case 'P':
  561. glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
  562. break;
  563. case 'l':
  564. case 'L':
  565. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  566. break;
  567.  
  568. /* case 's' :
  569. case 'S' :
  570. modelo.parado=!modelo.parado;
  571. break;*/
  572.  
  573.  
  574. }
  575.  
  576. if (estado.debug)
  577. printf("Carregou na tecla %c\n", key);
  578.  
  579. }
  580.  
  581. // Callback para interaccao via teclado (largar a tecla)
  582.  
  583. void KeyUp(unsigned char key, int x, int y)
  584. {
  585. switch (key) {
  586. // ... accoes sobre largar teclas ...
  587.  
  588. case 'Q':
  589. case 'q': estado.teclas.q = GL_FALSE;
  590. break;
  591. case 'A':
  592. case 'a': estado.teclas.a = GL_FALSE;
  593. break;
  594. case 'Z':
  595. case 'z': estado.teclas.z = GL_FALSE;
  596. break;
  597. case 'X':
  598. case 'x': estado.teclas.x = GL_FALSE;
  599. break;
  600.  
  601. }
  602.  
  603. if (estado.debug)
  604. printf("Largou a tecla %c\n", key);
  605. }
  606.  
  607. // Callback para interaccao via teclas especiais (carregar na tecla)
  608.  
  609. void SpecialKey(int key, int x, int y)
  610. {
  611. // ... accoes sobre outras teclas especiais ...
  612. // GLUT_KEY_F1 ... GLUT_KEY_F12
  613. // GLUT_KEY_UP
  614. // GLUT_KEY_DOWN
  615. // GLUT_KEY_LEFT
  616. // GLUT_KEY_RIGHT
  617. // GLUT_KEY_PAGE_UP
  618. // GLUT_KEY_PAGE_DOWN
  619. // GLUT_KEY_HOME
  620. // GLUT_KEY_END
  621. // GLUT_KEY_INSERT
  622.  
  623. switch (key) {
  624.  
  625.  
  626. case GLUT_KEY_UP:
  627. estado.teclas.up = GL_TRUE;
  628. break;
  629.  
  630. case GLUT_KEY_DOWN:
  631. estado.teclas.down = GL_TRUE;
  632. break;
  633.  
  634. case GLUT_KEY_LEFT:
  635. estado.teclas.left = GL_TRUE;
  636. break;
  637.  
  638. case GLUT_KEY_RIGHT:
  639. estado.teclas.right = GL_TRUE;
  640. break;
  641.  
  642.  
  643.  
  644. // redesenhar o ecra
  645. //glutPostRedisplay();
  646. }
  647.  
  648.  
  649. if (estado.debug)
  650. printf("Carregou na tecla especial %d\n", key);
  651. }
  652.  
  653. // Callback para interaccao via teclas especiais (largar na tecla)
  654.  
  655. void SpecialKeyUp(int key, int x, int y)
  656. {
  657. switch (key) {
  658.  
  659. case GLUT_KEY_UP:
  660. estado.teclas.up = GL_FALSE;
  661. break;
  662.  
  663. case GLUT_KEY_DOWN:
  664. estado.teclas.down = GL_FALSE;
  665. break;
  666.  
  667. case GLUT_KEY_LEFT:
  668. estado.teclas.left = GL_FALSE;
  669. break;
  670.  
  671. case GLUT_KEY_RIGHT:
  672. estado.teclas.right = GL_FALSE;
  673. break;
  674.  
  675.  
  676. }
  677.  
  678.  
  679. if (estado.debug)
  680. printf("Largou a tecla especial %d\n", key);
  681.  
  682. }
  683.  
  684. int main(int argc, char** argv)
  685. {
  686. // char str[]=" makefile MAKEFILE Makefile ";
  687. estado.doubleBuffer = 1;
  688.  
  689. glutInit(&argc, argv);
  690. glutInitWindowPosition(0, 0);
  691. glutInitWindowSize(640, 480);
  692. glutInitDisplayMode(((estado.doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE) | GLUT_RGB | GLUT_DEPTH);
  693. if (glutCreateWindow("Exemplo") == GL_FALSE)
  694. exit(1);
  695.  
  696. Init();
  697.  
  698. imprime_ajuda();
  699.  
  700. // Registar callbacks do GLUT
  701.  
  702. // callbacks de janelas/desenho
  703. glutReshapeFunc(Reshape);
  704. glutDisplayFunc(Draw);
  705.  
  706. // Callbacks de teclado
  707. glutKeyboardFunc(Key);
  708. glutKeyboardUpFunc(KeyUp);
  709. glutSpecialFunc(SpecialKey);
  710. glutSpecialUpFunc(SpecialKeyUp);
  711.  
  712. // callbacks timer/idle
  713. glutTimerFunc(estado.delayMovimento, Timer, 0);
  714.  
  715. // COMECAR...
  716. glutMainLoop();
  717. return 0;
  718. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement