X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=021962126e093ba94391bbfa15640caf70da6f2e;hb=41e8eb95882abe806e22b182768d2dd9361953d2;hp=3a948c8fbc7d8fb4e77e61a880d9e50d56cca2a1;hpb=1b8067182b0a43a8cb49ed32657146fd30b0b84b;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 3a948c8..0219621 100644 --- a/scene.c +++ b/scene.c @@ -464,15 +464,21 @@ 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 + GLdouble aspect = (GLfloat) h / (GLfloat) w; + GLdouble n = 10.0; - // Calculate The Aspect Ratio Of The Window - gluPerspective(45.0f,(GLfloat)w/(GLfloat)h,0.1f,100.0f); + glViewport(0, 0, w, h); - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); /* switch matrix mode*/ + glLoadIdentity(); + + 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 */ } /** @@ -493,10 +499,8 @@ 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 + glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red glVertex3f(-1.0f, 1.0f, 0.0f); // Top left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right