X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=c9ec1271fb968ee7b830df79e488493ae42b834b;hb=88cc1cef079f2ece6307c46634a0ef277fc38af8;hp=23f37eda565376ccc7934f75936a2260307d8088;hpb=9a7eff8658f05246667588a7efbe259aa0b7a488;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index 23f37ed..c9ec127 100644 --- a/scene.c +++ b/scene.c @@ -570,55 +570,30 @@ void display() { // lightPosition[3] = 1.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); + glutSolidTeapot(1); + glPushMatrix(); glDisable(GL_LIGHTING); + glColor3f(1.0, 1.0, 0.0); /* 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(); -} - -/** - * init function, sets OpenGL's starting state - */ -void init() { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - // gluPerspective( 60, 1, 0.1, 1000.0); - 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 */ + glPopMatrix(); - glMatrixMode(GL_MODELVIEW); + glutSwapBuffers(); } @@ -643,15 +618,18 @@ 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 @@ -661,9 +639,15 @@ int main(int argc, char **argv) { makeMenu(); - init(); + //init(); + + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glLineWidth(3.0); - glMatrixMode(GL_PROJECTION); +glMatrixMode(GL_PROJECTION); gluPerspective( /* field of view in degree */ 40.0, /* aspect ratio */ 1.0, /* Z near */ 20.0, /* Z far */ 100.0); @@ -672,7 +656,7 @@ int main(int argc, char **argv) { 0.0, 8.0, 0.0, /* center is at (0,8,0) */ 0.0, 1.0, 0.); /* up is in postivie Y direction */ - 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);