X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=a21c2997736febb1103c087a62c20fa64fbb1d4f;hp=d06dd3c3adca97d186b92b82f31de7ace8a43e16;hb=bb41d6092544e76540acf9700d2c14741a80ad6e;hpb=241ec710cf9e36891031b23e5bad89beb20c0944 diff --git a/scene.c b/scene.c index d06dd3c..a21c299 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(-near, far, -near*(GLfloat) h / (GLfloat) w, - far*(GLfloat) h / (GLfloat) w, nearClip, farClip); + glFrustum(-near, far, -near, + far, nearClip, farClip); else - glFrustum(-near*(GLfloat) w / (GLfloat) h, - far*(GLfloat) w / (GLfloat) h, near, far, nearClip, farClip); + glFrustum(-near*((GLfloat) w / (GLfloat) h), + far, near, far, nearClip, farClip); glMatrixMode(GL_MODELVIEW); } @@ -296,11 +296,11 @@ void display() { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - gluLookAt( - 0.0, 8.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 */ - ); + //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); @@ -347,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); @@ -360,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); @@ -405,15 +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 */ - // ); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glutReshapeFunc(windowReshape);