X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=7afde9cd41ca880037b945980ede82e8eef951d6;hp=e1b053fdd0a3f3a416a8dd836d97e0f7565c603a;hb=f8f4c489085c83bc31276148991166165085b557;hpb=b03479cc770df967f68e22319ee748dd26c448d4 diff --git a/scene.c b/scene.c index e1b053f..7afde9c 100644 --- a/scene.c +++ b/scene.c @@ -135,6 +135,13 @@ int drawFloorRecurse = 5; /* Size of floor, from -n to n */ 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 specular0[] = {1.0, 1.0, 1.0, 1.0}; +GLfloat light0_pos[] ={ 1.0, 2.0, 3,0, 1.0}; + + /** * Prints out error message when file cannot be read * @param fileName Name of file that could not be read @@ -632,20 +639,18 @@ void display() { drawFloor(); + // Draw teapot for a test object glPushMatrix(); - - glTranslatef(0.0, 1.0, 0.0); - glutWireTeapot(1); // Draw teapot for test + glTranslatef(0.0, 1.0, 0.0); // **NOTE: Teapot does not rest on surface + glutWireTeapot(1); glPopMatrix(); + // Draw a white ball over the light source glPushMatrix(); glDisable(GL_LIGHTING); glColor3f(1.0, 1.0, 1.0); - - /* Draw a yellow ball at the light source. */ glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]); glutSolidSphere(1.0, 50, 50); - glEnable(GL_LIGHTING); glPopMatrix(); @@ -662,23 +667,17 @@ void init() { glLoadIdentity(); gluPerspective( - 60.0, /* field of view in degree */ - 1.0, /* aspect ratio */ - near, /* Z near */ + 60.0, /* field of view in degree */ + 1.0, /* aspect ratio */ + near, /* Z near */ far /* Z far */ ); - -GLfloat diffuse0[] = {1.0, 1.0, 1.0, 1.0}; -GLfloat ambient0[] = {1.0, 1.0, 1.0, 1.0}; -GLfloat specular0[] = {1.0, 1.0, 1.0, 1.0}; -GLfloat light0_pos[] ={ 1.0, 2.0, 3,0, 1.0}; - -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); + 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); glEnable(GL_LIGHTING); glMatrixMode(GL_MODELVIEW); @@ -725,7 +724,6 @@ int main(int argc, char **argv) { glutDisplayFunc(display); glutMouseFunc(mouse); glutMotionFunc(motion); - //glutIdleFunc(idle); makeMenu();