(no commit message)
authorAsh Tyndall <[email protected]>
Sun, 9 Oct 2011 11:14:08 +0000 (19:14 +0800)
committerAsh Tyndall <[email protected]>
Sun, 9 Oct 2011 11:14:08 +0000 (19:14 +0800)
scene.c

diff --git a/scene.c b/scene.c
index 7e72ae6..4fea15a 100644 (file)
--- a/scene.c
+++ b/scene.c
@@ -463,7 +463,7 @@ void makeMenu() {
  * @param width New width\r
  * @param height New height\r
  */\r
-void windowReshape(int width, int height) {\r
+void windowReshape(int w, int h) {\r
   /*glViewport(0, 0, (GLsizei)width, (GLsizei)height);\r
   printf("Width: %d, height: %d\n", width, height);\r
   glMatrixMode(GL_PROJECTION);\r
@@ -476,6 +476,18 @@ void windowReshape(int width, int height) {
   GLdouble a = (GLfloat)height/(GLfloat)width;\r
   GLdouble fov = 60;\r
   glFrustum( -a*near*tan(fov/2),  a*near*tan(fov/2),  -a*near*tan(fov/2),  a*near*tan(fov/2), near, far  )*/\r
+  glViewport(0, 0, (GLsizei) w, (GLsizei) h); // what's GLsizei? Why is it called inside glViewPort?\r
+   glMatrixMode(GL_PROJECTION); // is it necessary to reset the projection matrix?\r
+   glLoadIdentity();\r
+   if (w <= h)  // is this calculation universal, could I use it on another program?\r
+      glOrtho(-5.0, 5.0, -5.0*(GLfloat)h/(GLfloat)w,\r
+               5.0*(GLfloat)h/(GLfloat)w, -5.0, 5.0);\r
+\r
+   else\r
+      glOrtho(-5.0*(GLfloat)w/(GLfloat)h,\r
+               5.0*(GLfloat)w/(GLfloat)h, -5.0, 5.0, -5.0, 5.0);\r
+   glMatrixMode(GL_MODELVIEW); // why do I set to GL_MODELVIEW at the end?\r
+   glLoadIdentity(); // why does it get a reset?\r
 }\r
 \r
 /**\r

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