X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=83e1c299eed996576613192e7f5ec15bf1e9e5c7;hp=bf5b7e89c61bc3cb43249b6eea6f4b3c2dfe494d;hb=8664ff7d3cbe2e5285d067231f54772b46649653;hpb=ee55eca6d8b23bd7cf6e536391c7e04719b2b8f8 diff --git a/scene.c b/scene.c index bf5b7e8..83e1c29 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(-1, 100, -1, - 100, -1, 100); - else - glFrustum(-1, - 100, -1, 100, -1, 100); - glMatrixMode(GL_MODELVIEW); + width = w; + height = h; } /** @@ -293,14 +286,31 @@ 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 = (float)height / (float)width; + if ( width > height ) aspect = (float)width / (float)height; + + gluPerspective( + 90.0, + aspect, + 0.1, + 100 + ); + 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, 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 */ + ); + + glRotatef(30.0, 1.0, 0.0, 0.0); /* Reposition the light source. */ lightPosition[0] = 12*cos(lightAngle);