X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=af6b86972f47222713d44d7bac1843ab1f250a52;hb=a3d862ad78fdf72f40e94495bd85b337e9505f98;hp=7ea99c881300be20394d9cd0474c33fa99463d70;hpb=b360766b6e3bf3808ff1991780e9e25828cee213;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 7ea99c8..af6b869 100644 --- a/scene.c +++ b/scene.c @@ -109,6 +109,17 @@ char *dirDefault2 = "/cslinux/examples/CITS2231/project-files/models-textures"; char dataDir[200]; // Stores the directory name for the meshes and textures. +static GLfloat floorVertices[4][3] = { + { -20.0, 0.0, 20.0 }, + { 20.0, 0.0, 20.0 }, + { 20.0, 0.0, -20.0 }, + { -20.0, 0.0, -20.0 }, +}; + +static GLfloat lightColor[] = {1.0, 1.0, 1.0, 1.0}; // White light +static GLfloat lightPosition[4]; +static float lightAngle = 10.0, lightHeight = 20; + /** * Prints out error message when file cannot be read * @param fileName Name of file that could not be read @@ -491,17 +502,10 @@ void mouse(int btn, int state, int x, int y) { } -static GLfloat floorVertices[4][3] = { - { -20.0, 0.0, 20.0 }, - { 20.0, 0.0, 20.0 }, - { 20.0, 0.0, -20.0 }, - { -20.0, 0.0, -20.0 }, -}; - -/* Draw a floor (possibly textured). */ -static void -drawFloor(void) -{ +/** + * Draw a floor. + */ +void drawFloor() { glDisable(GL_LIGHTING); //if (useTexture) { @@ -526,12 +530,6 @@ drawFloor(void) glEnable(GL_LIGHTING); } - -static GLfloat lightColor[] = {1.0, 1.0, 1.0, 1.0}; /* green-tinted */ -static GLfloat lightPosition[4]; -static float lightAngle = 10.0, lightHeight = 20; - - /** * Display function */ @@ -575,8 +573,8 @@ void display() { * init function; sets initial OpenGL state */ void init() { - glMatrixMode(GL_PROJECTION); + glLoadIdentity(); gluPerspective( 60.0, /* field of view in degree */ 1.0, /* aspect ratio */ @@ -585,9 +583,10 @@ void init() { ); glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); gluLookAt( 0.0, 8.0, 60.0, /* eye is at (0,8,60) */ - 0.0, 8.0, 0.0, /* center is at (0,8,0) */ + 0.0, 65.0, 0.0, /* center is at (0,8,0) */ 0.0, 1.0, 0.0 /* up is in postivie Y direction */ );