(no commit message)
[atyndall/cits2231.git] / scene.c
diff --git a/scene.c b/scene.c
index 1bafde5..e5d2a17 100644 (file)
--- a/scene.c
+++ b/scene.c
@@ -132,6 +132,8 @@ GLfloat angle2 = 30;   /* in degrees */
 GLfloat near = -10;\r
 GLfloat far = 10;\r
 \r
+static float zoomFactor = 1.0;\r
+\r
 /**\r
  * Prints out error message when file cannot be read\r
  * @param fileName Name of file that could not be read\r
@@ -490,12 +492,15 @@ void windowReshape(int w, int h) {
   glViewport(0, 0, (GLsizei) w, (GLsizei) h);\r
   glMatrixMode(GL_PROJECTION);\r
   glLoadIdentity();\r
+  GLfloat x = 2.0f*(200 + 0.5)/w-1.0;\r
+  GLfloat y = 2.0f*(200 + 0.5)/h-1.0;\r
+  glTranslatef(-x,-y,0.0f);\r
   if (w <= h) \r
-    glOrtho(near, far, near*(GLfloat)h/(GLfloat)w,\r
-             far*(GLfloat)h/(GLfloat)w, near, far);\r
+    glOrtho(zoomFactor*near, zoomFactor*far, zoomFactor*near*(GLfloat)h/(GLfloat)w,\r
+             zoomFactor*far*(GLfloat)h/(GLfloat)w, near, far);\r
   else\r
-    glOrtho(near*(GLfloat)w/(GLfloat)h,\r
-             far*(GLfloat)w/(GLfloat)h, near, far, near, far);\r
+    glOrtho(zoomFactor*near*(GLfloat)w/(GLfloat)h,\r
+             zoomFactor*far*(GLfloat)w/(GLfloat)h, zoomFactor*near, zoomFactor*far, near, far);\r
    glMatrixMode(GL_MODELVIEW); \r
    glLoadIdentity();\r
 }\r
@@ -675,9 +680,9 @@ void init() {
     );    \r
 \r
 \r
-GLfloat diffuse0[] = {1.0, 0.0, 0.0, 1.0};\r
-GLfloat ambient0[] = {1.0, 0.0, 0.0, 1.0};\r
-GLfloat specular0[] = {1.0, 0.0, 0.0, 1.0};\r
+GLfloat diffuse0[] = {1.0, 1.0, 1.0, 1.0};\r
+GLfloat ambient0[] = {1.0, 1.0, 1.0, 1.0};\r
+GLfloat specular0[] = {1.0, 1.0, 1.0, 1.0};\r
 GLfloat light0_pos[] ={ 1.0, 2.0, 3,0, 1.0};\r
 \r
 glEnable(GL_LIGHT0);\r

UCC git Repository :: git.ucc.asn.au