#include "glut.h"
typedef struct vertexTag {
	double x;
	double y;
}vertex;
void drawHouse(vertex peak, double width, double height);
void draw(void);
int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitWindowSize(400, 400);
	glutInitDisplayMode(GLUT_RGB);
	glutCreateWindow("A house");
	glutDisplayFunc(draw);
	glClearColor(0.0, 0.0, 0.0, 0.0);  //RGBA - A is Alpha, defines 
									   // degree of opacity
									   // 1.0 = fully opaque
									   // = fully transparent
	glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0); //defines orthoganal projection (parrallel
										   // viewing volume
										   // window limits of display
										   // left =0.0, right =2.0,
										   // bottom = 0.0, top = 2.0
										   // near =0.0, far = 1.0
										   //glOrtho2D(0.0, 2.0, 0.0, 2.0);      //2D version of above -no near or far
										   //	since it is a plane not a volume

	glutMainLoop();
	return 0;
}


void drawHouse(vertex peak, double width, double height)
{
	glBegin(GL_LINE_LOOP); //shell of house
	glColor3f(1.0, 1.0, 1.0);
	glVertex2f(peak.x, peak.y);
	glVertex2f(peak.x + width / 2, peak.y - 3 * height / 8);
	glVertex2f(peak.x + width / 2, peak.y - height);
	glVertex2f(peak.x - width / 2, peak.y - height);
	glVertex2f(peak.x - width / 2, peak.y - 3 * height / 8);
	glEnd();
	glBegin(GL_LINE_STRIP); //chimney
	glColor3f(1.0, 1.0, 1.0);
	glVertex2f(peak.x - width / 3, peak.y - height / 4);
	glVertex2f(peak.x - width / 3, peak.y);
	glVertex2f(peak.x - width / 6, peak.y);
	glVertex2f(peak.x - width / 6, peak.y - height / 8);
	glEnd();
}
void draw(void) {
	glClear(GL_COLOR_BUFFER_BIT);
	glLineWidth(2.0);
	vertex peak;  //declare instance of vertex;
	peak.x = 0.4; //place it
	peak.y = 1.9;
	drawHouse(peak, 0.2, 0.5);  //draw house at vertex peak
	peak.x = 1.4; //place it
	peak.y = 1.2;
	drawHouse(peak, -0.6, 0.3);  //draw house reflected in y-axis
	peak.x = 1.7; //place it
	peak.y = 0.4;
	drawHouse(peak, 0.1, -0.1);  //draw house reflected in x-axis
	peak.x = 0.2; //place it
	peak.y = 0.4;
	drawHouse(peak, -0.2, -0.2);  // house reflected in both axes
	glFlush();
}