How to update a certain value dependent on time, but not on the frame rate?

Hi, I am trying to figure out how to change the update parameter for my animation, so that it is independent of the framerate. Because I noticed the animation going faster if the framerate is going faster if i use this (simplified version, placed in renderscene):

   
	time = glutGet(GLUT_ELAPSED_TIME);
	if (time - timebase > speed) {
	  timebase = time;		
	  timestep++;	
	}

but now the timestep is incremented faster when the frame rate is faster, how can I make that independent of the framerate?

This code is not independent on the frame rate because it forgets any time that goes beyond the value of the speed variable. So if one frame takes 1.5 * speed, the 0.5 * speed will be forgotten in each loop and animation will play slower.

What you need is something like:

time = glutGet(GLUT_ELAPSED_TIME);
while ( ( time - timebase ) > speed ) {
    timebase += speed ;		
    timestep++;	
}

or matematical equivalent of the loop.

It works! thanks!