X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=7a7875fe75271fb18a0715a4a6f10d08e3bed516;hp=1bafde50ccb55a323d33fd9e310230f951b521d2;hb=336c0ba5151213006bd9537edef5d22368303519;hpb=6fbc798d09b7ceccd066d2898677bda36e6d592b diff --git a/scene.c b/scene.c index 1bafde5..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(); } @@ -675,9 +680,9 @@ void init() { ); -GLfloat diffuse0[] = {1.0, 0.0, 0.0, 1.0}; -GLfloat ambient0[] = {1.0, 0.0, 0.0, 1.0}; -GLfloat specular0[] = {1.0, 0.0, 0.0, 1.0}; +GLfloat diffuse0[] = {1.0, 1.0, 1.0, 1.0}; +GLfloat ambient0[] = {1.0, 1.0, 1.0, 1.0}; +GLfloat specular0[] = {1.0, 1.0, 1.0, 1.0}; GLfloat light0_pos[] ={ 1.0, 2.0, 3,0, 1.0}; glEnable(GL_LIGHT0);