X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=a99a692ddb15ed04459b4c93f5d55ccb708d9c1c;hp=f12ed3f679d10fffc62aff58641d1e961e5d9b43;hb=db7880146bfa1b0afc00228bf18eddf9770d315e;hpb=33a481008fc799fb11418627458e57d3e109b76b diff --git a/scene.c b/scene.c index f12ed3f..a99a692 100644 --- a/scene.c +++ b/scene.c @@ -124,7 +124,7 @@ GLfloat angle2 = 30; /* in degrees */ /* Near and far parameters */ GLfloat near = -10; -GLfloat far = 10; +GLfloat far = 20; /* Zoom factor for mouse movements */ GLfloat zoomFactor = 1.0; @@ -137,10 +137,11 @@ int floorSize = 100; /* Light 0 parameters */ GLfloat diffuse0[] = {1.0, 1.0, 1.0, 1.0}; -GLfloat ambient0[] = {1.0, 1.0, 1.0, 1.0}; +GLfloat ambient0[] = {0.0, 0.0, 0.0, 1.0}; GLfloat specular0[] = {1.0, 1.0, 1.0, 1.0}; GLfloat emission0[] = {0.0, 0.0, 0.0, 0.0}; GLfloat light0_pos[] ={1.0, 1.0, 0,0, 1.0}; +GLfloat glightmodel[] = {0.2,0.2,0.2,1}; /** @@ -664,8 +665,9 @@ void display() { // Draw teapot for a test object glPushMatrix(); - glTranslatef(0.0, 1.0, 0.0); // **NOTE: Teapot does not rest on surface - glutWireTeapot(1); + glTranslatef(0.0, 0.5, 0.0); // **NOTE: Teapot does not rest on surface + glColor3f(0.5, 0.5, 0.5); + glutSolidTeapot(1); glPopMatrix(); // Draw a white ball over the light source @@ -696,17 +698,20 @@ void init() { far /* Z far */ ); - glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, light0_pos); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0); glLightfv(GL_LIGHT0, GL_SPECULAR, specular0); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, glightmodel); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, specular0); glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, emission0); - glEnable(GL_COLOR_MATERIAL); - glEnable(GL_LIGHTING); + glMatrixMode(GL_MODELVIEW); glLoadIdentity();