// Here we are going to be drawing a cube with simple Vertex 
// Points in a group called GL_QUADS, this means that the
// object drawn will have 4 corners.
// We have to draw the corners from the bottom left, to the top left
// to the top right, to the bottom right.

// To set one of these corners we use the:
// glVertex3f(-0.5, -0.5, 0.0);
// command. This is drawing the first corner at -0.5 on the x axis
// and -0.5 on the y axis. The value on the z axis has not been changed
// as there is no need to move it forward or backward. We just want
// a simple square.

// After you have set up your vertices then just run the program, and if
// they are in the right order you will have a nice looking square.

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

void square (void) {
	glBegin(GL_QUADS); //begin the four sided shape
	glVertex3f(-0.5, -0.5, 0.0); //first corner at -0.5, -0.5
	glVertex3f(-0.5, 0.5, 0.0); //second corner at -0.5, 0.5
	glVertex3f(0.5, 0.5, 0.0); //third corner at 0.5, 0.5
	glVertex3f(0.5, -0.5, 0.0); //fourth corner at 0.5, -0.5
	glEnd(); //end the shape we are currently working on
}

void display (void) {
	glClearColor (0.0,0.0,0.0,1.0);
    glClear (GL_COLOR_BUFFER_BIT);
    glLoadIdentity();  
    gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
	square();
	glFlush();
}

void reshape (int w, int h) {
	glViewport (0, 0, (GLsizei)w, (GLsizei)h);
	glMatrixMode (GL_PROJECTION);
	glLoadIdentity ();
	gluPerspective (60, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
	glMatrixMode (GL_MODELVIEW);
}

int main (int argc, char **argv) {
    glutInit (&argc, argv);
	glutInitDisplayMode (GLUT_SINGLE);
	glutInitWindowSize (500, 500);
	glutInitWindowPosition (100, 100);
    glutCreateWindow ("A basic OpenGL Window");
    glutDisplayFunc (display);
	glutReshapeFunc (reshape);
    glutMainLoop ();
    return 0;
}


