parameterized house-pls help

i am very new to openGL. i’m trying to follow codes in the textbook to draw a parameterized house. but the program does not success. i guess it’s because something i dont declare, but i dunno how, and dunno where. this is my whole codes, can someone help me on this?

#include <GL\glut.h>

//------------------------------------------------------
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0); // set the background to white
glColor3f(0.0f, 0.0f, 0.0f); // set the drawing color to black

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,640.0,0.0,480.0);
}
//--------------------------------------------------
void parameterizedHouse(GLintPoint peak, GLint width,GLint height)
{
glBegin(GL_LINE_LOOP);
glVertex2i( peak.x, peak.y); // draw the shell of the house
glVertex2i( peak.x + width/2, peak.y -3 * height/8);
glVertex2i( peak.x + width/2, peak.y * height/8);
glVertex2i( peak.x - width/2, peak.y * height/8);
glVertex2i( peak.x - width/2, peak.y -3 * height/8);
glEnd();

}
//----------------------------------------------------
void myDisplay(void)
{
glClear( GL_COLOR_BUFFER_BIT );
parameterizedHouse();
glFlush();
}
//---------------------------------------------------
void main( int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize(640,480);
glutInitWindowPosition(0,0);
glutCreateWindow(“My House”);

glutDisplayFunc(myDisplay);

myInit();

glutMainLoop();
}

well, i modified the code (below) so that it actually compiles/runs. it doesn’t draw a house, but it does display something. if you want to draw a house, you need to modify the parameterizedHouse function so that the vertices actually specify the points which would define a house’s outline. oh, and the numbers i pass into the house function are totally random right now – i just wanted to see if it would draw anything.

#include <GL\glut.h>

typedef struct {
int x;
int y;
} point;

//------------------------------------------------------
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0); // set the background to white
glColor3f(0.0f, 0.0f, 0.0f); // set the drawing color to black

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,640.0,0.0,480.0);
}
//--------------------------------------------------
void parameterizedHouse(point peak, GLint width, GLint height){
glBegin(GL_LINE_LOOP);
glVertex2i( peak.x, peak.y); // draw the shell of the house
glVertex2i( peak.x + width/2, peak.y -3 * height/8);
glVertex2i( peak.x + width/2, peak.y * height/8);
glVertex2i( peak.x - width/2, peak.y * height/8);
glVertex2i( peak.x - width/2, peak.y -3 * height/8);
glEnd();
}
//----------------------------------------------------
void myDisplay(void)
{
point p;
p.x = 100;
p.y = 200;
glClear( GL_COLOR_BUFFER_BIT );
parameterizedHouse(p, 300, 300);
glFlush();
}
//---------------------------------------------------
void main( int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize(640,480);
glutInitWindowPosition(0,0);
glutCreateWindow(“My House”);

glutDisplayFunc(myDisplay);

myInit();

glutMainLoop();
}

thank you very much. it draws something now .

i got another problem. i have drawn the shell of the house and add a door, but it draws a house that turns upside down. may i know what’s the real problem?

void parameterizedHouse(point peak, GLint width,GLint height)
{

glBegin(GL_LINE_LOOP);
glVertex2i( peak.x, peak.y); // draw the shell of the house
glVertex2i( peak.x + width/2, peak.y -3 * height/8);
glVertex2i( peak.x + width/2, peak.y * height/8);
glVertex2i( peak.x - width/2, peak.y * height/8);
glVertex2i( peak.x - width/2, peak.y -3 * height/8);
glEnd();

glBegin(GL_LINE_LOOP); //draw the door
glVertex2i( peak.x +width/5, peak.y -10 *height/20);
glVertex2i( peak.x +width/5, peak.y *height/20);
glVertex2i( peak.x -width/8, peak.y *height/20);
glVertex2i( peak.x -width/8, peak.y -10 *height/20);
glEnd();
}
//-------------------------------------------------------------------
void myDisplay(void)
{
point p;
p.x = 150;
p.y = 150;
glClear( GL_COLOR_BUFFER_BIT );
parameterizedHouse(p,250,250);
glFlush();
}

thanks for ur help

Wutup Fuyu…Here is my parametrized house code you can work with.
This function uses a GLintPoint object and I have included implementation of this class below. Its very short and succinct as you can see.
Good Luck Hombre

//GLintPoint Class
class GLintPoint
{
public:
int x,y;
GLintPoint(int a, int b)
{x=a,y=b;}

};

void parametrizedHouse(GLintPoint peak,GLint width,GLint height)
{
GLint ChWidth = width/50;
GLint DoorWidth = width/10;
GLint DoorHeight= height/10;
GLint WindowW= width/10;
GLint WindowH= height/10;
//Skeleton of the House
glBegin(GL_LINE_LOOP);
glVertex2i((GLint)peak.x,peak.y);

	GLintPoint secondPoint((GLint)peak.x+width/2, (GLint)peak.y-3*height/8);
	glVertex2i(secondPoint.x,secondPoint.y);

	GLintPoint thirdPoint((GLint)peak.x+width/2, (GLint)peak.y-height);
	glVertex2i(thirdPoint.x,thirdPoint.y);

	GLintPoint fourthPoint((GLint)peak.x-width/2,(GLint)peak.y-height);
	glVertex2i(fourthPoint.x,fourthPoint.y);

	GLintPoint fifthPoint((GLint)peak.x-width/2,(GLint)peak.y-3*height/8);
	glVertex2i(fifthPoint.x,fifthPoint.y);
glEnd();
//Chimeney of the house
glBegin(GL_LINE_STRIP);
	glVertex2i(((peak.x+fifthPoint.x)/2)-ChWidth, ((peak.y+fifthPoint.y)/2)-ChWidth);
	glVertex2i(((peak.x+fifthPoint.x)/2)-ChWidth,peak.y);
	glVertex2i(((peak.x+fifthPoint.x)/2)+ChWidth,peak.y);
	glVertex2i(((peak.x+fifthPoint.x)/2)+ChWidth,((peak.y+fifthPoint.y)/2)+ChWidth);
glEnd();
//Door of the House
glBegin(GL_LINE_STRIP);
	glVertex2i(((thirdPoint.x+fourthPoint.x)/2)-DoorWidth,fourthPoint.y);
	glVertex2i(((thirdPoint.x+fourthPoint.x)/2)-DoorWidth,fifthPoint.y-DoorHeight);
	glVertex2i(((thirdPoint.x+fourthPoint.x)/2)+DoorWidth,fifthPoint.y-DoorHeight);
	glVertex2i(((thirdPoint.x+fourthPoint.x)/2)+DoorWidth,fourthPoint.y);
glEnd();
//Window of the House
glBegin(GL_LINE_LOOP);
	glVertex2i(((thirdPoint.x+((thirdPoint.x+fourthPoint.x)/2)+DoorWidth)/2)-WindowW,fifthPoint.y-DoorHeight);
	glVertex2i(((thirdPoint.x+((thirdPoint.x+fourthPoint.x)/2)+DoorWidth)/2)-WindowW,fifthPoint.y-DoorHeight+WindowH);
	glVertex2i(((thirdPoint.x+((thirdPoint.x+fourthPoint.x)/2)+DoorWidth)/2)+WindowW,fifthPoint.y-DoorHeight+WindowH);
	glVertex2i(((thirdPoint.x+((thirdPoint.x+fourthPoint.x)/2)+DoorWidth)/2)+WindowW,fifthPoint.y-DoorHeight);
glEnd();
glFlush();

}