// Computer Graphics - Amir Hesami // line_strip.cpp #include #pragma comment(lib, "opengl32.lib") // Link OpenGL32.lib #pragma comment(lib, "glu32.lib") // Link Glu32.lib #pragma comment(lib, "glut32.lib") // Link Glut32.lib void display(); void init( ); int main(int argc, char** argv) { //Initialize glut and specifies command line options glutInit(&argc, argv); //Initializes opreation's mode and coloring system glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //Specifying the window's size glutInitWindowSize(500,500); //Specifying the window's position glutInitWindowPosition(100,100); //Create the window glutCreateWindow("Line Strip"); //Calling the drawing function glutDisplayFunc(display); init(); //Runing the program glutMainLoop(); return 0; } void display(void) { glClear(GL_COLOR_BUFFER_BIT);//clear buffers glColor3f(1.0, 0.0, 0.0); glBegin(GL_LINE_STRIP); glVertex2f(0.25, 0.25); glVertex2f(0.75, 0.25); glVertex2f(0.75, 0.75); glVertex2f(0.25, 0.75); glEnd(); glFlush(); } void init(void) { glClearColor(1.0, 1.0, 1.0, 1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, 1.0, 0.0, 1.0); }