X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=6f028970eda07b4fdaa13ed693d7a0e2e09b399c;hb=d518aa46819c76d7b080865471bb23031bb0fbf5;hp=7ea99c881300be20394d9cd0474c33fa99463d70;hpb=b360766b6e3bf3808ff1991780e9e25828cee213;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 7ea99c8..6f02897 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,16 +573,17 @@ 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 */ 0.0, /* Z near */ 900.0 /* Z far */ ); - + glLoadIdentity(); 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) */