/******************************************************************** File: curve.cc Draws a circle as a line strip. D. Vrajitoru. ********************************************************************/ #include #include #include const int CURVE_ID = 1; // display a curve as a line strip void read_file(char *filename) { ifstream fin; int nr_points; float x, y; fin.open(filename); fin >> nr_points; glNewList(CURVE_ID, GL_COMPILE); glColor3f(1, 0, 0); glBegin(GL_LINE_STRIP); for (int i=0; i> x >> y; glVertex2f(x, y); } glEnd(); glEndList(); fin.close(); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glCallList(CURVE_ID); glFlush(); } void myinit() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1.25, 1.25, -1.25, 1.25); glMatrixMode(GL_MODELVIEW); glClearColor (1.0, 0.95, 0.9, 1.0); glColor3f(1.0,0.0,0.0); } void main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB ); glutInitWindowSize(300, 300); glutCreateWindow("plot"); glutDisplayFunc(display); myinit(); glutMainLoop(); }