X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=scene.c;h=d1c7cf21a912592862cf3ef6e1b0523b5d52857f;hb=02a8a651d1897a11d266dcd93d27b7f1d4c03a84;hp=0c5329b2d01d38f5f52c0f66e6eeb991bc5002fb;hpb=84eea711e741871dfb6cc595a0989e1369998d7f;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 0c5329b..d1c7cf2 100644 --- a/scene.c +++ b/scene.c @@ -184,7 +184,15 @@ void makeMenu() { */ void windowReshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); - // **NOTE: windowReshape needs to be re-written using glFrustrum and perspective projection calculations + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glFrustum(-near, far, -near*(GLfloat) h / (GLfloat) w, + far*(GLfloat) h / (GLfloat) w, nearClip, farClip); + else + glFrustum(-near*(GLfloat) w / (GLfloat) h, + far*(GLfloat) w / (GLfloat) h, near, far, nearClip, farClip); + glMatrixMode(GL_MODELVIEW); } /** @@ -391,13 +399,13 @@ int main(int argc, char **argv) { glLineWidth(1.0); // **NOTE: Currently the perspective and look-at code is static, for testing purposes - glMatrixMode(GL_PROJECTION); - gluPerspective( - 40.0, /* field of view in degree */ - 1.0, /* aspect ratio */ - 1.0, /* Z near */ // **NOTE: Seems to be issue with near < 0 causing invisible everything - 100.0 /* Z far */ - ); + //glMatrixMode(GL_PROJECTION); + //gluPerspective( + // 40.0, /* field of view in degree */ + // 1.0, /* aspect ratio */ + // 1.0, /* Z near */ // **NOTE: Seems to be issue with near < 0 causing invisible everything + // 100.0 /* Z far */ + // ); glMatrixMode(GL_MODELVIEW); gluLookAt(