#include <GLUT/glut.h>
#include <OpenGL/gl.h>

void renderer(void);
void initialSetup(void);
void changeSize(GLsizei w, GLsizei h);

int main (int argc, const char * argv[]) 
{
    glutInit(&argc, (char **)argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("First Program");
    glutDisplayFunc(renderer);
    glutReshapeFunc(changeSize);
    initialSetup();
    glutMainLoop();
    return 0;
}

void renderer(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,0.0,0.0);
    glRectf(100.0f, 150.0, 150.0, 100);
    glFlush();
}

void changeSize(GLsizei w, GLsizei h)
{
    if(h==0)
        h = 1;
    
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    
    if(w <= h)
        glOrtho(0, 250, 0, 250.0 * h/w, 1, -1);
    else
        glOrtho(0,250.0 * w/h, 0, 250, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}


void initialSetup(void)
{
    glClearColor(0.0, 1.0, 0.0, 1.0);
}