X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=7a7875fe75271fb18a0715a4a6f10d08e3bed516;hp=e3004ee8d6450eb1e2966d9e8172a4911dcbbf9a;hb=336c0ba5151213006bd9537edef5d22368303519;hpb=4bce415af0e0be9392c2725a8fc4f9a3cc0fad11 diff --git a/scene.c b/scene.c index e3004ee..7a7875f 100644 --- a/scene.c +++ b/scene.c @@ -132,6 +132,8 @@ GLfloat angle2 = 30; /* in degrees */ GLfloat near = -10; GLfloat far = 10; +static float zoomFactor = 0.0; + /** * Prints out error message when file cannot be read * @param fileName Name of file that could not be read @@ -490,12 +492,15 @@ void windowReshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); + GLfloat x = 2.0f*(200 + 0.5)/w-1.0; + GLfloat y = 2.0f*(200 + 0.5)/h-1.0; + glTranslatef(-x,-y,0.0f); if (w <= h) - glOrtho(near, far, near*(GLfloat)h/(GLfloat)w, - far*(GLfloat)h/(GLfloat)w, near, far); + glOrtho(zoomFactor*near, zoomFactor*far, zoomFactor*near*(GLfloat)h/(GLfloat)w, + zoomFactor*far*(GLfloat)h/(GLfloat)w, near, far); else - glOrtho(near*(GLfloat)w/(GLfloat)h, - far*(GLfloat)w/(GLfloat)h, near, far, near, far); + glOrtho(zoomFactor*near*(GLfloat)w/(GLfloat)h, + zoomFactor*far*(GLfloat)w/(GLfloat)h, zoomFactor*near, zoomFactor*far, near, far); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }