X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=af2d52c398280e3013e2c948952161c5ef3bbb39;hp=a09011c0099d9101857010aaba2c66d4aafe22ce;hb=b0a8c04c993514d979c7bff6a56ad5e437ce38b9;hpb=4d0f02e34869112ca94fd2b3a061af58fe9af548 diff --git a/scene.c b/scene.c index a09011c..af2d52c 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, - far, 1, 100); - else - glFrustum(-near*((GLfloat) w / (GLfloat) h), - far, near, far, 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( + 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); @@ -311,7 +321,7 @@ void display() { glPushMatrix(); /* Perform scene rotations based on user mouse/keyboard input. */ - glRotatef(angle, 0.0, 1.0, 0.0); + glRotatef(angle, 0.0, 0.0,1.0); glRotatef(angle2, 1.0, 0.0, 0.0); glTranslatef(camx, camy, camz); glRotatef(rot, 1.0, 0.0, 0.0); @@ -400,6 +410,7 @@ int main(int argc, char **argv) { 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);