diff options
author | Stijn Buys <ingar@osirion.org> | 2011-05-11 14:48:17 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-05-11 14:48:17 +0000 |
commit | 1c63cbf204b1d2c667ce9f821ccb197d0ffb0ac3 (patch) | |
tree | c2d0ff7cc4a8a264657abd0ac99017a5b664ecd2 /src/core/timer.cc | |
parent | bb0f860989f84b901f80017ae0139a3fc0446dc1 (diff) |
Review of the main loop timer, converted timers from float to unsigned long,
corrected a number of timing bugs, improved client framerate stability.
Diffstat (limited to 'src/core/timer.cc')
-rw-r--r-- | src/core/timer.cc | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/core/timer.cc b/src/core/timer.cc deleted file mode 100644 index 6f2e914..0000000 --- a/src/core/timer.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - core/timer.cc - This file is part of the Osirion project and is distributed under - the terms and conditions of the GNU General Public License version 2 -*/ - -#include "core/timer.h" - -#include <unistd.h> -#include <iostream> -#include <cmath> - -namespace core -{ - -Timer::Timer() -{ - gettimeofday(&this->timer_tick, &this->timer_tz); - this->timer_elapsed = 0; -} - -Timer::~Timer() -{ -} - -void Timer::mark() -{ - gettimeofday(&timer_tick, &timer_tz); -} - -unsigned long Timer::timestamp() -{ - struct timeval tick; - struct timezone tick_tz; - - gettimeofday(&tick, &tick_tz); - - // calculate elapsed time in 10^-6 seconds - unsigned long delta = 0; - delta = tick.tv_sec * 1000 + tick.tv_usec / 1000; - delta -= timer_tick.tv_sec * 1000 + timer_tick.tv_usec / 1000; - return delta; -} - -float Timer::elapsed() -{ - return ((float) timestamp() / 1000.0f); -} - -} |