/******************************************************************** File: interface.cc Author: Dana Vrajitoru Project: A fractal program Last updated: January 30, 2017. Interface functions for the fractal program. ********************************************************************/ #include "glheader.h" #include "interface.h" #include "sierpinski.h" #include int width = 500, height = 500; /* initial triangle */ Point2 v[]={{-1.0, -0.58}, {1.0, -0.58}, {0.0, 1.15}}; int n; // Create a window and set up the GUI functions void createWindowGUI() { glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB ); glutInitWindowSize(width, height); glutCreateWindow("2D Gasket"); glutReshapeFunc(myResize); glutDisplayFunc(display); //glutIdleFunc(display); glutKeyboardFunc(key); //glutSpecialFunc(spkey); //glutMouseFunc(mouse); } // Application parameters void myinit() { n = 5; glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1.25, 1.25, -1.25, 1.25); glMatrixMode(GL_MODELVIEW); glClearColor (0, 0, 0, 1.0);//black glColor3f(1.0,0.0,0.0); // red //glLineWidth(2); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE); } // To be called whenever the window is resized. void myResize(int w, int h) { width = w; height = h; glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1.25, 1.25, -1.25, 1.25); glMatrixMode(GL_MODELVIEW); } // Callback function for the display void display(void) { glClear(GL_COLOR_BUFFER_BIT); glClearColor (0, 0, 0, 1.0);//black glColor3f(1.0,0.0,0.0); // red divide_triangle(v[0], v[1], v[2], n); glFlush(); } // Callback function for an Ascii key being pressed void key(unsigned char key, int x, int y) { switch (key) { case 'q': case 'Q': exit(0); case '1': n = 2; glutPostRedisplay(); break; } } // Callback function for a special key being pressed void spkey(int key, int x, int y) { switch (key) { case GLUT_KEY_LEFT: glutPostRedisplay(); break; case GLUT_KEY_RIGHT: glutPostRedisplay(); break; } }