From f459b7ee740cbf5c5e96987b0871261429cae84c Mon Sep 17 00:00:00 2001 From: Ash Tyndall Date: Sun, 9 Oct 2011 14:57:26 +0800 Subject: [PATCH] --- scene.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/scene.c b/scene.c index 1530f08..a2f1514 100644 --- a/scene.c +++ b/scene.c @@ -464,23 +464,20 @@ void makeMenu() { * @param h New height */ void windowReshape(int w, int h) { - /* glViewport(0, 0, w, h); // Reset The Current Viewport - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - - // Calculate The Aspect Ratio Of The Window - gluPerspective(45.0f,45.0f,0.1f,100.0f); - - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix*/ + GLfloat aspect = (GLfloat) h / (GLfloat) w; + GLdouble n = 10.0; glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); /* switch matrix mode*/ glLoadIdentity(); - if (w <= h) - gluOrtho2D(-10.0, 10.0, -10.0 * (GLfloat) h / (GLfloat) w, 10.0 * (GLfloat) h / (GLfloat) w); - else - gluOrtho2D(-10.0 * (GLfloat) w / (GLfloat) h, 10.0 * (GLfloat) w / (GLfloat) h, -10.0, 10.0); + + if (w <= h) { + gluOrtho2D(-n, n, -n * aspect, n * aspect); + } else { + gluOrtho2D(-n * aspect, n * aspect, -n, n); + } + glMatrixMode(GL_MODELVIEW); /* return to modelview mode */ } @@ -502,8 +499,6 @@ void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); - //glTranslatef(-1.5f, 0.0f, -6.0f); - glBegin(GL_QUADS); glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red glVertex3f(-1.0f, 1.0f, 0.0f); // Top left -- 2.20.1