Public Group

# Speed -- how to delay ?

This topic is 3811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello everybody, My problem is I need draw One light Point ( in OpenGL ) that moves between two points A and B with t parameter like this equation: A(x1,y1,z1) & B(x2,y2,z2) the equation: x = t*(x1-x2) + x2; y = t*(y1-y2) + y2; z = t*(z1-z2) + z2; t is increased by the value: (example )0.xxxxxx until t = 1 then stop. The program that run on my computer looks nice but look too fast(low) when it is run on other computer that are more powerful( powerless ). I don't know how to do to it have the same speed ? Thank for all.

##### Share on other sites
What your problem is, is how to implement animation. There's probably tons of tutorials and articles, many on this site. But to give a quick introduction:

There are basically two ways of doing this. In both cases you set a loop for rendering, much as you've done.

In the first method, at the start of the loop you call whatever system function you need to get the current time in fractions of a second. Subtract from this what you got on the previous cycle of the loop to get the amount of real time it took to go through the loop the last time. Then you simply advance your animation time in steps of Δt, which is the duration of time we compute at the beginning of the loop. In your case this means that your add Δt to t.

The second method is to keep the time step Δt constant. You add Δt to t as before, but this time t corresponds to animation time, which we wish to keep in sync with real time. You do this at the beginning of the loop by computing the amount of real time that has passed since the animation started and if that is less that your current value of t you make the program sleep for a duration equal to the difference.

##### Share on other sites
thank SnotBob,

but i mean this: with same parameter t when on my computer it look nice but when other computer it look fast. I do not know to fix it ?

##### Share on other sites
The reason why it's going faster on a faster computer is precisely because you do not take into account the time it actually takes to display your animation. I explained in my previous post two ways to fix your problem. Why don't you try out the first one.

##### Share on other sites
Yes,
Yes,
I am bored...
Seemly i have no ways to fix my problem. Someone has curtain way , please tell me. Thanks.

##### Share on other sites
OpenX,

Whats the difference between the two machines? Different CPUs?

You might be seeing a difference between the cycle speed, if your counting the number of clock cycles before moving the item then you would get different speeds on different hardware platforms.

##### Share on other sites
Another computer might have a higher framerate than yours, which means it updates faster. Updating faster means the animation will go much quicker. What you want is Time Based Movement or Frame Independent Movement. Google it.

##### Share on other sites
Thank Tenac . Can you explain that more detail. I cannot limit my frame rate or speed when my program run on another computer. It will too fast if that one is more powerful.

##### Share on other sites
unlikely nobody will provide you with a complete implementation, which is what you would like to receive.

It's very easy to implement so google it, or make some effort as same question has been answered on this forum recently with code provided.

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009391
• ### Who's Online (See full list)

There are no registered users currently online

×