time step

Hiya,

I am trying to simulate the flow of oil in the earth formation but am having difficulty with the time step. What I intend to do is to draw a frame, stop for 0.1 second and draw the second one. I have been trying to use the C++ clock_t command without much success. Any help is greatly appreciated. Thanks.

Suf.

You can use glutTimerFunc( t=ms, routine, int number).

example

glutTimerFunc( 100, My_timer, 1);

void My_timer(int t_id)
{
// do stuff

glutTimerFunc( 100, My_timer, 1); // reset timer, timer function is a one shot timer. Will not be called again unless reset.
}

Originally posted by Suf:
[b]Hiya,

I am trying to simulate the flow of oil in the earth formation but am having difficulty with the time step. What I intend to do is to draw a frame, stop for 0.1 second and draw the second one. I have been trying to use the C++ clock_t command without much success. Any help is greatly appreciated. Thanks.

Suf.[/b]

//
/** wait for 1/fps seconds **/
/
/

void Wait(int fps)
{
clock_t t1, t2;

t1 = clock(); /** regulate frame rate **/
for(; [img]http://www.opengl.org/discussion_boards/ubb/wink.gif[/img]
{
	t2 = clock();
	if(((double)(t2-t1) / CLOCKS_PER_SEC) > ((double)1/(double) fps))
		break;
}

}

It worked. Thanks guys! If you are in Edinburgh, I would buy you a cup of coffee!

Suf