Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: mapers en 28 Octubre 2010, 04:13 am



Título: opengl rotacion
Publicado por: mapers en 28 Octubre 2010, 04:13 am
quisiera que me ayudaran a poder rotar por si solo el cuadrado que e dibujado estoy tratando pero no veo resultados sigue estatico y no se mueve
Código
  1. #include <windows.h>
  2. #ifdef __APPLE__
  3. #include <GLUT/glut.h>
  4. #else
  5. #include <GL/glut.h>
  6. #endif
  7.  
  8. #include <stdlib.h>
  9. #include <GL/glut.h>
  10. #define ancho 320
  11. #define altura 240
  12. #define profundidad 500
  13. void DibujaCuadrado();
  14. void EjesXY();
  15. void Teclado(unsigned char tecla, int x, int y);
  16. int angulo=0;
  17. int main(int argc, char** argv) {
  18. glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
  19. glutInitWindowPosition(100, 0);
  20. glutInitWindowSize(ancho, altura);
  21. glutCreateWindow("Rotación de un Cuadrado en 2D");
  22. glOrtho(-(ancho/2), (ancho/2), -(altura/2), (altura/2), -profundidad, profundidad);
  23. glClearColor(1, 1, 1, 0);
  24. glutDisplayFunc(DibujaCuadrado);
  25. glutKeyboardFunc(Teclado);
  26. glutMainLoop();
  27. return 0;
  28. }
  29. void DibujaCuadrado() {
  30. glClear(GL_COLOR_BUFFER_BIT);
  31. EjesXY();
  32. glPushMatrix();
  33. glRotatef(angulo, 0, 0, 1);
  34. glBegin(GL_QUADS);
  35. glColor3f(1, 0, 0);glVertex2i(50,50);
  36. glColor3f(1, 1, 0);glVertex2i(-50, 50);
  37. glColor3f(1, 0, 0);glVertex2i(-50, -50);
  38. glColor3f(1, 1, 0);glVertex2i(50, -50);
  39. glEnd();
  40. glPopMatrix();
  41. glutSwapBuffers();
  42. }
  43. void EjesXY() {
  44. glColor3f(1.0, 0.0, 1.0);
  45. glBegin(GL_LINES);
  46. glVertex2i(-ancho/2, 0);
  47. glVertex2i(ancho/2, 0);
  48. glVertex2i(0, altura/2);
  49. glVertex2i(0, -altura/2);
  50. glEnd();
  51. }
  52. void Teclado(unsigned char tecla, int x, int y) {
  53. while(angulo=!0)
  54. {
  55. angulo++;
  56.  
  57. }
  58. glutPostRedisplay();
  59. }
  60.