X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=642fdcdc5bfce55a355ca9e68597233e8effdc66;hp=af2d52c398280e3013e2c948952161c5ef3bbb39;hb=ec50cae176e4a0ec67a756f779adbdf700362924;hpb=b0a8c04c993514d979c7bff6a56ad5e437ce38b9 diff --git a/scene.c b/scene.c index af2d52c..642fdcd 100644 --- a/scene.c +++ b/scene.c @@ -291,8 +291,12 @@ void display() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - float aspect = (float)height / (float)width; - if ( width > height ) aspect = (float)width / (float)height; + float aspect; + if ( width <= height ) { + aspect = (float)height / (float)width; + } else { + aspect = (float)width / (float)height; + } gluPerspective( 75.0, @@ -321,7 +325,7 @@ void display() { glPushMatrix(); /* Perform scene rotations based on user mouse/keyboard input. */ - glRotatef(angle, 0.0, 0.0,1.0); + glRotatef(angle, 0.0, 1.0, 0.0); glRotatef(angle2, 1.0, 0.0, 0.0); glTranslatef(camx, camy, camz); glRotatef(rot, 1.0, 0.0, 0.0); @@ -336,7 +340,9 @@ void display() { glPushMatrix(); glTranslatef(0.0, 0.5, 0.0); // **NOTE: Teapot currently does not rest on surface glColor3f(0.0, 0.0, 0.0); + glFrontFace(GL_CW); glutSolidTeapot(1); + glFrontFace(GL_CCW); glPopMatrix(); // Draw a white ball over the light source @@ -367,11 +373,11 @@ void init() { glLightModelfv(GL_LIGHT_MODEL_AMBIENT, glightmodel); - 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); + 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); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); @@ -408,10 +414,10 @@ int main(int argc, char **argv) { glDepthRange(0,1); glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // the type - glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); + glEnable(GL_CULL_FACE); glEnable(GL_NORMALIZE); - glLineWidth(1.0); + glLineWidth(2.0); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);