PDA

View Full Version : time step



Suf
10-03-2002, 11:27 AM
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.

nexusone
10-03-2002, 11:52 AM
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:
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.

Gavin
10-04-2002, 03:48 AM
/****************************/
/** wait for 1/fps seconds **/
/****************************/

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

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

Suf
10-04-2002, 05:17 AM
It worked. Thanks guys! If you are in Edinburgh, I would buy you a cup of coffee!

Suf