X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=1d72da5ee96000018f240c9cb5da77b8ab301d19;hb=f12982461fe7d471e2a9825c382ebcaf6df0c1c1;hp=bad6fa2da8ec8dcd0ec192fcccc9f227ffb35b63;hpb=bf2accaa2aadac8e1d5d1d4d8457e76480eedf6f;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index bad6fa2..1d72da5 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,12 +573,8 @@ void display() { * init function; sets initial OpenGL state */ void init() { - glEnable(GL_CULL_FACE); - glEnable(GL_DEPTH_TEST); - glEnable(GL_TEXTURE_2D); - glLineWidth(3.0); - glMatrixMode(GL_PROJECTION); + glLoadIdentity(); gluPerspective( 60.0, /* field of view in degree */ 1.0, /* aspect ratio */ @@ -588,7 +582,8 @@ void init() { 900.0 /* Z far */ ); - //glMatrixMode(GL_MODELVIEW); + 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) */ @@ -633,6 +628,9 @@ int main(int argc, char **argv) { glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // the type + glEnable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + glLineWidth(3.0); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);