X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=79c506e416821bcdccd30f3d0ad5cde31c8e235a;hb=79f4b6e1d83d5ec50cfac2f71487bd9d07d8fc8e;hp=3e0f34f5c2a708ad83b160c018af88a76d414f48;hpb=023daaaaab63ad4475c5839c7218407903815958;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 3e0f34f..79c506e 100644 --- a/scene.c +++ b/scene.c @@ -491,6 +491,42 @@ 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) +{ + glDisable(GL_LIGHTING); + + //if (useTexture) { + // glEnable(GL_TEXTURE_2D); + //} + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex3fv(floorVertices[0]); + glTexCoord2f(0.0, 16.0); + glVertex3fv(floorVertices[1]); + glTexCoord2f(16.0, 16.0); + glVertex3fv(floorVertices[2]); + glTexCoord2f(16.0, 0.0); + glVertex3fv(floorVertices[3]); + glEnd(); + + /*if (useTexture) { + glDisable(GL_TEXTURE_2D); + }*/ + + glEnable(GL_LIGHTING); +} + + /** * Display function */ @@ -498,25 +534,26 @@ void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); - glTranslatef( 0.0f, 0.0f, 0.0f); + /*glTranslatef( 0.0f, 0.0f, 0.0f); glBegin(GL_QUADS); glVertex3f( 0.0f, 1.0f, -1.0f); glVertex3f( 0.0f, 1.0f, 1.0f); glVertex3f( 0.0f, -1.0f, 1.0f); glVertex3f( 0.0f, -1.0f, -1.0f); - glEnd(); + glEnd();*/ glTranslatef( 0.0f, 0.0f, -5.0f); // Move into the Screen 10.0 glutSolidTeapot(1); - glMatrixMode(GL_MODELVIEW); + /* glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.7f, 0.4f, 0.9f, -2.0f, -1.0f, -7.0f, 1.0f, 10.0f, 1.0f); glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + glLoadIdentity();*/ + drawFloor(); glutSwapBuffers(); } @@ -571,5 +608,14 @@ int main(int argc, char **argv) { init(); + glMatrixMode(GL_PROJECTION); + gluPerspective( /* field of view in degree */ 40.0, + /* aspect ratio */ 1.0, + /* Z near */ 20.0, /* Z far */ 100.0); + glMatrixMode(GL_MODELVIEW); + 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, 1.0, 0.); /* up is in postivie Y direction */ + glutMainLoop(); }