#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

// Variable Declarations
int deviceWindowWidth;
int deviceWindowHeight;

void init() {   
   glLoadIdentity();
   gluOrtho2D(0.0, 1.0, 0.0, 1.0);
   
   glClearColor(0.0, 0.0, 0.6, 0.0);
   glColor3f(1.0, 1.0, 0.0);
   glLineWidth(5.0);
}

void lineLoop() {
    glBegin(GL_LINE_LOOP);
      glVertex2d(0.05, 0.50);
      glVertex2d(0.50, 0.95);
      glVertex2d(0.95, 0.50);
      glVertex2d(0.50, 0.05);
    glEnd();
}
   
void display() {
    glClear(GL_COLOR_BUFFER_BIT);

    // Create First Instance of the Geometry
    glViewport((int) (0.0*deviceWindowWidth), (int) (0.0*deviceWindowHeight),
               (int) (0.5*deviceWindowWidth), (int) (1.0*deviceWindowHeight));
    lineLoop();

    // Create Second Instance of the Geometry
    glViewport((int) (0.5*deviceWindowWidth), (int) (0.0*deviceWindowHeight),
               (int) (0.5*deviceWindowWidth), (int) (1.0*deviceWindowHeight));
    lineLoop();
    
    glFlush();
   
}

void reshape(int width, int height) {
   deviceWindowWidth  = width;
   deviceWindowHeight = height;
}

int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(500, 500);
    glutCreateWindow("Hello Line Loop World");

    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
   
    init();
   
    glutMainLoop();
    return 0;
}