#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

using namespace std;

#define WIDTH 800
#define HEIGHT 600

void init(void) 
{
	GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
	GLfloat mat_shininess[] = { 100.0 };
	GLfloat light_position[] = { .2, 1.0, 1.0, 0.0 };
	glClearColor (0.3, 0.1, 1.0, 0.0);
	glShadeModel (GL_SMOOTH);

	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
	glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_DEPTH_TEST);
}

void display(void)
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();

	gluLookAt(
		0,0,-5, // eye
		0,0,0,
		0,1,0
		);

	glColor3ub(255,255,225);


	glBegin(GL_QUADS);
	glVertex3f(3,	-1,	6);
	glVertex3f(3,	-1,	-3);
	glVertex3f(-1.5,	-1,	-3);
	glVertex3f(-2,	-1,	6);
	glEnd();

	glTranslatef(0, .25, 0);

	glutSolidSphere (1.0, 64, 64); 
	glTranslatef(1,-.5,.5);
	
	glutSolidSphere (.75, 64, 64); 
	glFlush ();
}

void reshape (int w, int h)
{
	glViewport (0, 0, (GLsizei) w, (GLsizei) h);
	glMatrixMode (GL_PROJECTION);
	glLoadIdentity();

	gluPerspective(45.0, 1.0 * WIDTH / HEIGHT, 1, 1000);


	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

static void Key(unsigned char key, int x, int y)
{
	switch (key) {
		case 27:
			exit(0);
	}
}

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize (WIDTH, HEIGHT); 
	glutCreateWindow ("CG2 Assign1 - Adam Damiano and Leaf Corcoran");
	init();
	glutDisplayFunc(display); 
	glutReshapeFunc(reshape);

	glutKeyboardFunc(Key);
	glutMainLoop();
	return 0;
}
