X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=bf5b7e89c61bc3cb43249b6eea6f4b3c2dfe494d;hp=fe67e1395e4e8f3a710e1fad549f0c1af57e8ce5;hb=ee55eca6d8b23bd7cf6e536391c7e04719b2b8f8;hpb=4bcc8e39f5d73c7b210a48d3ca4dcd53ed8fb37e diff --git a/scene.c b/scene.c index fe67e13..bf5b7e8 100644 --- a/scene.c +++ b/scene.c @@ -187,11 +187,11 @@ void windowReshape(int w, int h) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) - glFrustum(-1.0, 1.0, -1.0*(GLfloat) h / (GLfloat) w, - 1.0*(GLfloat) h / (GLfloat) w, 2.0, 10.0); + glFrustum(-1, 100, -1, + 100, -1, 100); else - glFrustum(-1.0*(GLfloat) w / (GLfloat) h, - 1.0*(GLfloat) w / (GLfloat) h, -1.0, 1.0, 2.0, 10.0); + glFrustum(-1, + 100, -1, 100, -1, 100); glMatrixMode(GL_MODELVIEW); } @@ -293,8 +293,15 @@ void motion(int x, int y) { */ void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + //gluLookAt( + // -30.0, -30.0, -30.0, /* eye is at (x,y,z) */ + /// 0.0, 0.0, 0.0, /* center is at (x,y,z) */ + // 0.0, 1.0, 0.0 /* up is in postivie Y direction */ + // ); + /* Reposition the light source. */ lightPosition[0] = 12*cos(lightAngle); lightPosition[1] = lightHeight; @@ -340,9 +347,6 @@ void display() { * init function; sets initial OpenGL state */ void init() { - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glLightfv(GL_LIGHT0, GL_POSITION, light0_pos); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0); @@ -353,11 +357,11 @@ void init() { glLightModelfv(GL_LIGHT_MODEL_AMBIENT, glightmodel); - glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); - glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); - glMaterialfv(GL_FRONT, GL_SPECULAR, specular); - glMaterialfv(GL_FRONT, GL_EMISSION, emission0); - glMaterialf(GL_FRONT, GL_SHININESS, shine); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emission0); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shine); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); @@ -398,22 +402,6 @@ int main(int argc, char **argv) { glEnable(GL_TEXTURE_2D); 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_MODELVIEW); - gluLookAt( - 0.0, 35.0, -20.0, /* eye is at (x,y,z) */ - 0.0, 10.0, 0.0, /* center is at (x,y,z) */ - 0.0, 1.0, 0.0 /* up is in postivie Y direction */ - ); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glutReshapeFunc(windowReshape);