X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=e9b4c796193e71f8d5dcc048e73c61a400deb316;hb=00f9bfb76669b8b6061be500b96125ed4c29dcb7;hp=b50bae1261c443c064c98307c6fe5d0c30032da4;hpb=fa5eba8e23e8445fdcaed45f474a9ab1c308f794;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index b50bae1..e9b4c79 100644 --- a/scene.c +++ b/scene.c @@ -460,15 +460,24 @@ void makeMenu() { /** * Called when window is resized - * @param w New width - * @param h New height + * @param width New width + * @param height New height */ 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); - glMatrixMode(GL_MODELVIEW); + + gluPerspective(60, (GLfloat)width / (GLfloat)height, 0.0, 1000.0); + + /*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 */ } /**