Elapsed Time Help

Sorry, I am new here and I tried the search function…

I actually want this ball to go down 1 meter for every second.
I know I should use glutTimerFunc, but I really google-ed
for any reference and I couldn’t find any that could help me. and the falling speed should double at every second.

Any example or reference is greatly appreciated…

You can use glutGet(GLUT_ELAPSED_TIME)
It returns the number of milliseconds since glutInit was called.

In SDL you can use SDL_GetTicks() as another option. Same thing as glut, it returns the milliseconds since SDL was initialized.

I created a very simple class to track up to 100 timers with SDL which I use for debugging execution speeds for code blocks:

class Timer
          //The clock time when the timer started
          float startTicks[99];

          //Clock time when the timer was stopped
          float splitTicks[99];

          //The various clock actions
          void start(int type);
          void stop(int type);

void Timer::start(int type) {
     //Get the current clock time
     startTicks[type] = SDL_GetTicks();

void Timer::stop(int type) {
     //Set the stop time
     splitTicks[type]=SDL_GetTicks() - startTicks[type];

I have a much more complex version that has many more features, but this is just to give an example.