OpenGL Library for Delphi,
maintained by Eric Grange,
based on Mike Lischke's GLScene.

 

Articles - Cadencer progression event


The cadencer triggers "progression events", unlike a Timer, these events do not happen at a fixed interval, they'll usually happen once the previous
frame is complete (the faster everything gets rendered, the more progression events you'll get).

To be able to make use of those progression events, you need some timing information, two are provided:

1) newTime
2) deltaTime

The base paradigm is that of a simulation, newTime is the new simulated time (or the current time if you prefer), deltaTime is the time interval since the last progression event (it's just given as a help, you could compute it by subtracting newTime between progression events).

In your progression event you are supposed to make things move, and make them move in a framerate independant manner (so that your program does not become super fast or unstable fast on a faster machine), which will require you to make movements, reactivity to user actions, AI, etc. time-based. In short, you're supposed to integrate over deltaTime, or use "formula(newTime)" movements/actions.

Instead of having progressions like

newPosition = oldPosition + speed

you should rather have something like

newPosition = oldPosition + speed*deltaTime

However if you have fixed-time steps requirements (can usually be avoided),
you can always choose to ignore a progression event and wait for some time
to have happened (accumulate deltaTime into a variable of yours, and wait
for a sufficient amount of time to have been accumulated).


This document is a extraction from the newsgroup and was written by Eric Grange.
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0660 seconds