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

#include <cmath>

int deviceWindowWidth;
int deviceWindowHeight;

void init() {   
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluOrtho2D(-1.0, -1.0, 1.0, 1.0);
   
   glClearColor(1.0, 0.85, 0.85, 0.0);
   glColor3f(0.0, 0.0, 0.8);
   glLineWidth(3.0);
}

void drawCircle() {
	double PI = 3.14159;
	double angleInRadians;
	double radius = 0.9;
	
	glBegin(GL_LINE_LOOP);
	   for (int angle=0; angle<360; angle+=15) {
	      angleInRadians = angle*PI/180.0;
	      double x = radius*cos(angleInRadians);
	      double y = radius*sin(angleInRadians);
	      glVertex2d(x, y);
	   }   
	glEnd();
}

void drawDisk() {
	double PI = 3.14159;
	double angleInRadians;
	double radius = 0.9;

      glBegin(GL_POLYGON);
	   for (int angle=0; angle<360; angle+=5) {
	      angleInRadians = angle*PI/180.0;
	      double x = radius*cos(angleInRadians);
	      double y = radius*sin(angleInRadians);
	      glVertex2d(x, y);
	   }   
	glEnd();
}
	  
void display() {
    glClear(GL_COLOR_BUFFER_BIT);
    
    // Set the Viewport and Draw the Geometry
    glViewport((int)(0.0*deviceWindowWidth), (int)(0.5*deviceWindowHeight),
               (int)(1.0*deviceWindowWidth), (int)(0.5*deviceWindowHeight));
    drawCircle();
            
    glViewport((int)(0.0*deviceWindowWidth), (int)(0.0*deviceWindowHeight),
               (int)(1.0*deviceWindowWidth), (int)(0.5*deviceWindowHeight));
    drawDisk();   

    glFlush();
}

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

int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitWindowPosition(10, 10);
    glutInitWindowSize(400, 800);
    glutCreateWindow("Circle Disk");

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