From: Ash Tyndall Date: Sun, 9 Oct 2011 07:10:27 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=commitdiff_plain;h=1f911126b87d5e8f7788738b970836a6b8ba11c1 --- diff --git a/scene.c b/scene.c index b50bae1..8905850 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)height / (GLfloat)width, 0.1, 1000.0); + else + gluPerspective(60, (GLfloat)width / (GLfloat)height, 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 */ } /**