Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: mapers en 14 Septiembre 2010, 06:57 am



Título: glut
Publicado por: mapers en 14 Septiembre 2010, 06:57 am
replantee todo  ahora solo quiero que cuando haga click en la  ventana  me vuelva a mostra otro grafico ......................................
Código
  1. #include<windows.h>
  2. #include <GL/glut.h>
  3. #define ancho 320
  4. #define altura 240
  5. #define profundidad 500
  6. void DibujaCuadrado();
  7. void ejesxy();
  8. void TecladoMovimiento(int tecla, int x, int y);
  9. int posx=0, posy=0;
  10. int main(int argc, char** argv) {
  11. glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
  12. glutInitWindowPosition(100, 0);
  13. glutInitWindowSize(500, 500);
  14. glutCreateWindow("GRAFICADOR ");
  15. glOrtho(-20, 300, -40, 200, -profundidad, profundidad);
  16. glClearColor(1, 1, 1, 0);
  17. glutDisplayFunc(DibujaCuadrado);
  18. glutMainLoop();
  19. return 0;
  20. }
  21. void DibujaCuadrado() {
  22. glClear(GL_COLOR_BUFFER_BIT);
  23. ejesxy();
  24. glPushMatrix();
  25. glTranslatef(posx, posy,0);
  26. glBegin( GL_LINE_STRIP );
  27.  for(int i=0;i<300;i++)
  28.  {
  29.      int x=rand()%100;
  30.  
  31.  
  32.   //draw polyline
  33.    glVertex2i( i, x );
  34.    glVertex2i( i, 0 );
  35.  
  36.  }
  37. glEnd();
  38. glPopMatrix();
  39. glutSwapBuffers();
  40. }
  41. void ejesxy() {
  42. glColor3f(1.0, 0.0, 0.0);
  43. glBegin(GL_LINES);
  44. glVertex2f(-20, 0);
  45. glVertex2f(300, 0);
  46. glVertex2f(0, 200);
  47. glVertex2f(0, -40);
  48. glEnd();
  49. }
  50.  
  51.