X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=0bae91750f25d50949cd364720beda211dec808b;hb=94e5c40733517114b3f0e75c8c88c033dc80aee3;hp=736d5e655cc02129b82a1927bf7bd36fc4ceb55a;hpb=0400887e2592bc89a03ed29b105cb3c5f26e02ac;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 736d5e6..0bae917 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 */ @@ -589,20 +583,19 @@ void init() { ); glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); gluLookAt( - 0.0, 8.0, 60.0, /* eye is at (0,8,60) */ + 0.0, 8.0, 50000.0, /* eye is at (0,8,60) */ 0.0, 8.0, 0.0, /* center is at (0,8,0) */ 0.0, 1.0, 0.0 /* up is in postivie Y direction */ ); - glTranslatef( 0.0f, 0.0f, -600.0f); // Move into the Screen 10.0 - - /*glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05); glEnable(GL_LIGHT0); - glEnable(GL_LIGHTING);*/ + glEnable(GL_LIGHTING); } /** @@ -635,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);