CSE167: Code samples to be used in Assignment 3 1. For depth buffering: a. In main(), modify glutInit flag: glutInit(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH); b. In your OpenGL state initialization function: glEnable(GLUT_DEPTH); c. Before rendering your primitives: glClear(GL_COLOR_BUFFER|GL_DEPTH_BUFFER) 2. For animation: (to start and stop animation using a menu item) 1. Define a global boolean animation state variable: bool animationState=FALSE; 2. Define a global trackPositionVariable (this parametrizes the current track position from 0-maxValue) double trackPositionVariable=0.0 3. In menuCB (menu callback function) in the case of user selecting animation toggle item: if (!animationState) { glutIdleFunc(advanceTrackPosition); } else { glutIdleFunc(NULL); } animationState = (!animationState); 4. Implement a callback function: advanceTrackPosition() which is called whenever the application is idle. void advanceTrackPosition() { trackPositionVariable+=(.01); if (trackPositionVariable >maxValue) trackPositionVariable = 0.0; glutPostRedisplay(); } 5. Now, in your renderScene function, use the trackPositionVariable to calculate where on the train model should be positioned (translated to). You can also find the tangent to the track at this location which will determine how the train model should be rotated.