X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=4852a51833bdab7c197ce2516440fde0c0f28159;hb=71afe748d9068eefceef10fd828c95e3a4c65606;hp=b50bae1261c443c064c98307c6fe5d0c30032da4;hpb=fa5eba8e23e8445fdcaed45f474a9ab1c308f794;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index b50bae1..4852a51 100644 --- a/scene.c +++ b/scene.c @@ -467,8 +467,21 @@ void windowReshape(int width, int height) { glViewport(0, 0, (GLsizei)width, (GLsizei)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(60, 1.0, 0.1, 1000.0); + + if (width <= height) + gluPerspective(60, (GLfloat)width / (GLfloat) height, 0.1, 1000.0); + else + gluPerspective(60, (GLfloat)height / (GLfloat) width, 0.1, 1000.0); glMatrixMode(GL_MODELVIEW); + + /*glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); /* switch matrix mode + glLoadIdentity(); + if (w <= h) + gluOrtho2D(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w, 2.0 * (GLfloat) h / (GLfloat) w); + else + gluOrtho2D(-2.0 * (GLfloat) w / (GLfloat) h, 2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0); + glMatrixMode(GL_MODELVIEW); /* return to modelview mode */ } /**