Use open gl Write code MyDisplay not pseudocode to draw a pi

Use open gl

Write code MyDisplay (not pseudo-code) to draw a picture by calling a routine parametrizedHouse(peak, width, height) that are the same for all houses with the same peak, width, height values. It is not required to write myInit and main functions.


Do not write parametrizedHouse(peak, width, height) function, assume that it is given. Tiling should be done by using the loop of mapping of the world window to the viewport window with changing their parameters not parameters of the parametrizedHouse(peak, width, height) function. The code inside of you loop should reflect house flipping.


Tip: Assume that the arrays of coordinated (4 points: L, R, B,T) of all tiles is given as well as coordinates of the viewports where each house is located.


Check that the house that flipped horizontally is really flipped.
Check that the house that flipped vertically is really flipped.

Solution

#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();
}

Use open gl Write code MyDisplay (not pseudo-code) to draw a picture by calling a routine parametrizedHouse(peak, width, height) that are the same for all house

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site