X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=8b52285d89ac58a262add566cf61db38722edf26;hb=bbcc709acd8f62bd313215c7e71710f3ebcf01c0;hp=638683e95c05a4d7fb817c282d537057b32aefac;hpb=a94c1e2ec02ba03c8f7c4dee751f2eded3203b8f;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 638683e..8b52285 100644 --- a/scene.c +++ b/scene.c @@ -527,7 +527,7 @@ drawFloor(void) } -static GLfloat lightColor[] = {0.8, 1.0, 0.8, 1.0}; /* green-tinted */ +static GLfloat lightColor[] = {1.0, 1.0, 1.0, 1.0}; /* green-tinted */ static GLfloat lightPosition[4]; static float lightAngle = 0.0, lightHeight = 20; @@ -536,71 +536,39 @@ static float lightAngle = 0.0, lightHeight = 20; * Display function */ void display() { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glLoadIdentity(); - - /*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();*/ - - - //glTranslatef( 0.0f, 0.0f, -5.0f); // Move into the Screen 10.0 - //glutSolidTeapot(1); - - /* 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();*/ - + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity(); - /* Reposition the light source. */ + /* Reposition the light source. */ lightPosition[0] = 12*cos(lightAngle); lightPosition[1] = lightHeight; lightPosition[2] = 12*sin(lightAngle); - //if (directionalLight) { - lightPosition[3] = 0.0; - //} else { - // lightPosition[3] = 1.0; - //} + lightPosition[3] = 0.0; - glPushMatrix(); - - /* Tell GL new light source position. */ + glPushMatrix(); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); - /* Draw "bottom" of floor in blue. */ - glFrontFace(GL_CW); /* Switch face orientation. */ - glColor4f(0.1, 0.1, 0.7, 1.0); - drawFloor(); - glFrontFace(GL_CCW); - - /* Draw "top" of floor. Use blending to blend in reflection. */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(0.7, 0.0, 0.0, 0.3); - glColor4f(1.0, 1.0, 1.0, 0.3); drawFloor(); glDisable(GL_BLEND); - glPushMatrix(); - glDisable(GL_LIGHTING); + glutSolidTeapot(1); // Draw teapot for test + + glPushMatrix(); + glDisable(GL_LIGHTING); + glColor3f(1.0, 1.0, 0.0); - /* Draw a yellow ball at the light source. */ + /* Draw a yellow ball at the light source. */ glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]); glutSolidSphere(1.0, 5, 5); - glEnable(GL_LIGHTING); + glEnable(GL_LIGHTING); glPopMatrix(); - drawFloor(); - glutSwapBuffers(); + glPopMatrix(); + + glutSwapBuffers(); } @@ -625,18 +593,17 @@ int main(int argc, char **argv) { glutInit(&argc, argv); - //glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL | GLUT_MULTISAMPLE); glutInitWindowSize(500, 500); glutCreateWindow("Scene Editor"); - //glShadeModel(GL_SMOOTH); // Enables Smooth Shading - //glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background - //glClearDepth(1.0f); // Depth Buffer Setup - //glEnable(GL_DEPTH_TEST); // Enables Depth Testing - //glDepthFunc(GL_LEQUAL); // the type + glShadeModel(GL_SMOOTH); // Enables Smooth Shading + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background + glClearDepth(1.0f); // Depth Buffer Setup + glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glDepthFunc(GL_LEQUAL); // the type // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations