What you are really asking is how to do animation in OpenGL. In other words, how does one make OpenGL do computations and update the display automatically instead of in response to a key being pressed? In your case you want OpenGL to change the color of an object, count to 10 seconds, then change the color back. This is the same thing as asking OpenGL to rotate a teapot automatically instead of in response to a key being held down on the keyboard. For OpenGL animation (using GLUT) look up glutIdleFunc. For keeping track of when 10 seconds has elapsed see glutGet(GLUT_ELAPSED_TIME).