Paremeterization of Hardwired House

I think this is one of those basic assignments that’s here commonly :doh:, but I’m trying to understand it as opposed to just copy.

The code is as so:

#include <GL/freeglut.h>
#include <GL/GL.h>
#include <GL/GLU.h>
#include <Windows.h>
#include <fstream>
using namespace std;

struct GLintPoint{
	GLint x, y;
};

void parameterizedHouse(GLintPoint peak, GLint width, GLint height){
	glBegin(GL_LINE_LOOP);
	glVertex2i(peak.x, peak.y);  // draw shell of house
	glVertex2i(peak.x + width/2, peak.y -3* height/8);
	glVertex2i(peak.x + width / 2,  peak.y - height);
	glVertex2i(peak.x - width / 2, peak.y - height); 
	glVertex2i(peak.x - width / 2, peak.y - 3 * height / 8);
	glEnd();
	glBegin(GL_LINE_LOOP);//draw window
	glVertex2i(peak.x + width / 3, peak.y - 5*height / 10);
	glVertex2i(peak.x + width / 6, peak.y - 5*height / 10);
	glVertex2i(peak.x + width / 6, peak.y - 5 * height / 10);
	glVertex2i(peak.x + width / 6, peak.y - 6 * height / 10);
	glVertex2i(peak.x + width / 6, peak.y - 6 * height / 10);
	glVertex2i(peak.x + width / 3, peak.y - 6 * height / 10);
	glEnd();
	glBegin(GL_LINES);
	glVertex2i(peak.x - width / 2, peak.y - height);
	glVertex2i(peak.x - width / 2, peak.y - height);
	glEnd();


}

void houseCallBack(void){
	GLintPoint k;
	k.x = 200;
	k.y = 200;
	glClear(GL_COLOR_BUFFER_BIT);
	parameterizedHouse(k, 100, 100);
	glFlush();
}
void hardwiredHouse(void)
{
	glBegin(GL_LINE_LOOP);
	glVertex2i(40, 40);	// draw the shell of house 
	glVertex2i(40, 90);
	glVertex2i(70, 120);
	glVertex2i(100, 90);
	glVertex2i(100, 40);
	glEnd();
	glBegin(GL_LINE_STRIP);
	glVertex2i(50, 100);	// draw the chimney 
	glVertex2i(50, 120);
	glVertex2i(60, 120);
	glVertex2i(60, 110);
	glEnd();
	glBegin(GL_LINE_STRIP);//draw the 
	glVertex2i(50, 40);
	glVertex2i(50, 70);
	glVertex2i(70, 70);
	glVertex2i(70, 40);
	glEnd();
	glBegin(GL_LINE_STRIP);
	glVertex2i(80, 70);
	glVertex2i(80, 60);
	glVertex2i(90, 60);
	glVertex2i(90, 70);
	glVertex2i(80, 70);
	//
	//glVertex2i()
	glEnd();

}

void myInit(void){
	glClearColor(0.0, 1.0, 1.0, 1.0); //sets backgrounnd color 
	glColor3f(0.8, 0.7, 0.4);//drawing color
	glPointSize(8.0); //sets point size
	glMatrixMode(GL_PROJECTION); //from the eye of the "camera"
	glLoadIdentity();//Loads Identity Matrix
	gluOrtho2D(0.0, 640.0, 0, 480.0); //sets orthogonal x, y coord

}

void myDisplay(void){
	//glClear(GL_COLOR_BUFFER_BIT); //clear of any drawings
	hardwiredHouse();
	//glBegin(GL_LINE_STRIP); //tells the computer to start with points
	//glEnd();
	glFlush();
}

int main(int argc, char**argv){
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowPosition(100, 100);
	glutInitWindowSize(700, 700);
	glutCreateWindow("Hi, Shaun!");
	glutDisplayFunc(houseCallBack);
	myInit();
	glutMainLoop();
}

I am trying to develop a parametrized version of the hardWiredHouse. Thusfar, I have the window, and that was achieved by just looking at other verticies and literally hacking away at it until the lines were aligned, then changing to GL_LINE_LOOP once I had enough aligned vertices.

My question is: is there a more algorithmic approach to doing this aside from subbing in numbers based on the vertices already given for the house skeleton?


void hardwiredHouse(void) 
{
 glBegin(GL_LINE_LOOP); glVertex2i(40, 40); // draw the shell of house
 glVertex2i(40, 90);
glVertex2i(70, 120); 
glVertex2i(100, 90);
 glVertex2i(100, 40); 
glEnd(); 
glBegin(GL_LINE_STRIP); 
glVertex2i(50, 100); // draw the chimney glVertex2i(50, 120); 
glVertex2i(60, 120);
glVertex2i(60, 110);
 glEnd();
 . . . // draw the door . . . // draw the window } 

My guess is that I need to take the hardWiredVerticies I made and see how they relate? e.g. for

	glVertex2i(50, 100);	// draw the chimney 
	glVertex2i(50, 120);
	glVertex2i(60, 120);
	glVertex2i(60, 110);

do something of (50/50) (120/100) to see what formula arises for each vertex relative to the former?:dejection:

Thank you
Partition