X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=cb6fd4e7eca2bea194fe8f1604f867fb4570a9ba;hp=3216d15abf744044db4e593fd65e0c42741f9225;hb=f5b13f83e5c772873a2ecf72ca33bdd848c2efe9;hpb=f3ffdbeff05ea19ba064c32fa38c00aaa0482666 diff --git a/scene.c b/scene.c index 3216d15..cb6fd4e 100644 --- a/scene.c +++ b/scene.c @@ -184,15 +184,8 @@ void makeMenu() { */ void windowReshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - glFrustum(-near, far, -near*((GLfloat) h / (GLfloat) w), - far*((GLfloat) h / (GLfloat) w), nearClip, farClip); - else - glFrustum(-near*((GLfloat) w / (GLfloat) h), - far*((GLfloat) w / (GLfloat) h), near, far, nearClip, farClip); - glMatrixMode(GL_MODELVIEW); + width = w; + height = h; } /** @@ -293,14 +286,35 @@ void motion(int x, int y) { */ void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + // Redraw projection matrix + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + float aspect; + if ( width <= height ) { + aspect = (float)height / (float)width; + } else { + aspect = (float)width / (float)height; + } + + gluPerspective( + 75.0, + aspect, + 0.1, + 200 + ); + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - //gluLookAt( - // -30.0, -30.0, -30.0, /* eye is at (x,y,z) */ - /// 0.0, 0.0, 0.0, /* center is at (x,y,z) */ - // 0.0, 1.0, 0.0 /* up is in postivie Y direction */ - // ); + gluLookAt( + 0.0, 0.0, 5.0, /* eye is at (x,y,z) */ + 0.0, 0.0, 0.0, /* center is at (x,y,z) */ + 0.0, 1.0, 0.0 /* up is in postivie Y direction */ + ); + + glRotatef(75.0, 1.0, 0.0, 0.0); /* Reposition the light source. */ lightPosition[0] = 12*cos(lightAngle); @@ -398,8 +412,8 @@ int main(int argc, char **argv) { glDepthRange(0,1); glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // the type - glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); + glEnable(GL_NORMALIZE); glLineWidth(1.0); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);