#include #include GLfloat vert1X = 0.25, vert1Y = 0.25, vert2X = 0.75, vert2Y = 0.25, vert3X = 0.75, vert3Y = 0.75; void display(void) { /* clear all pixels */ glClear(GL_COLOR_BUFFER_BIT); /* draw red polygon (triangle)*/ glColor3f(1.0, 0.0, 0.0); glBegin(GL_POLYGON); glVertex2f(vert1X, vert1Y); glVertex2f(vert2X, vert2Y); glVertex2f(vert3X, vert3Y); glEnd(); /* dont wait * start processing buffered OpenGL routines */ glFlush(); } void init(int arg, char* arg_vec[]) { /* select clearing (background) color */ glClearColor(0.0, 0.0, 0.0, 0.0); vert1X = atof (arg_vec[1]); vert1Y = atof (arg_vec[2]); vert2X = atof (arg_vec[3]); vert2Y = atof (arg_vec[4]); vert3X = atof (arg_vec[5]); vert3Y = atof (arg_vec[6]); /* initialize viewing values */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); } int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(450, 450); glutInitWindowPosition(0,0); glutCreateWindow("Drawing Objects"); init(argc, argv); glutDisplayFunc(display); glutMainLoop(); return 0; }