replantee todo ahora solo quiero que cuando haga click en la ventana me vuelva a mostra otro grafico ......................................
#include<windows.h>
#include <GL/glut.h>
#define ancho 320
#define altura 240
#define profundidad 500
void DibujaCuadrado();
void ejesxy();
void TecladoMovimiento(int tecla, int x, int y);
int posx=0, posy=0;
int main(int argc, char** argv) {
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
glutInitWindowPosition(100, 0);
glutInitWindowSize(500, 500);
glutCreateWindow("GRAFICADOR ");
glOrtho(-20, 300, -40, 200, -profundidad, profundidad);
glClearColor(1, 1, 1, 0);
glutDisplayFunc(DibujaCuadrado);
glutMainLoop();
return 0;
}
void DibujaCuadrado() {
glClear(GL_COLOR_BUFFER_BIT);
ejesxy();
glPushMatrix();
glTranslatef(posx, posy,0);
glBegin( GL_LINE_STRIP );
for(int i=0;i<300;i++)
{
int x=rand()%100;
//draw polyline
glVertex2i( i, x );
glVertex2i( i, 0 );
}
glEnd();
glPopMatrix();
glutSwapBuffers();
}
void ejesxy() {
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_LINES);
glVertex2f(-20, 0);
glVertex2f(300, 0);
glVertex2f(0, 200);
glVertex2f(0, -40);
glEnd();
}