Changeset 7367 for code/branches/doc/src/libraries/util/Clock.h
- Timestamp:
- Sep 6, 2010, 3:51:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/util/Clock.h
r7331 r7367 41 41 via Clock& references (for instance for the game tick). <br> 42 42 Precision: <br> 43 @par Precision 43 44 The maximum precision is given by the Ogre::Timer and that is somewhere 44 45 in the microsecond range for both Windows and UNIX. 45 @ remarks46 @par Remarks for Usage on Windows 46 47 For proper functionality this class MUST be used in the same thread! <br> 47 Further 48 caveat on Windows because it will only capture the time on the same49 C PU core. Confining the main thread to one process could speed up the game.50 See command line argument 'limitToCPU'.48 Furthermore it might be possible that the Ogre::Timer has a performance 49 caveat because it will only capture the time on the same CPU core. 50 Confining the main thread to one process could speed up the game. 51 See \ref cmdargspage "Ccommandline Argument" 'limitToCPU' (only on Windows) 51 52 */ 52 53 class _UtilExport Clock 53 54 { 54 55 public: 55 // !Starts the time at 056 /// Starts the time at 0 56 57 Clock(); 57 58 ~Clock(); 58 59 59 //! Internally captures the time and stays at that particular time 60 /** Internally captures the time and stays at that particular time 61 @remarks 62 Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned 63 long, which will eventually overflow. But if you use the subtraction of 64 the current time minus the last time the timer gave us and sum these up to 65 a 64 bit integer, we get the desired result. <br> 66 Also mind that we don't have to store the last timer's time as unsigned long 67 as well because (unsigned long)tickTime_ will do exactly that. 68 */ 60 69 void capture(); 61 70 62 // !Returns the last captured absolute time in microseconds71 /// Returns the last captured absolute time in microseconds 63 72 unsigned long long getMicroseconds() const 64 73 { return tickTime_; } 65 // !Returns the last captured absolute time in milliseconds74 /// Returns the last captured absolute time in milliseconds 66 75 unsigned long long getMilliseconds() const 67 76 { return tickTime_ / 1000; } 68 // !Returns the last captured absolute time in seconds77 /// Returns the last captured absolute time in seconds 69 78 unsigned long getSeconds() const 70 79 { return static_cast<long> (tickTime_ / 1000000); } 71 // !Returns the last captured absolute time in seconds as float80 /// Returns the last captured absolute time in seconds as float 72 81 float getSecondsPrecise() const 73 82 { return static_cast<float>(tickTime_ / 1000000.0f); } 74 83 75 // !Returns the timespan in seconds between the last two calls to capture()84 /// Returns the timespan in seconds between the last two calls to capture() 76 85 float getDeltaTime() const 77 86 { return tickDtFloat_; } 78 // !Returns the timespan in microseconds between the last two calls to capture()87 /// Returns the timespan in microseconds between the last two calls to capture() 79 88 long getDeltaTimeMicroseconds() const 80 89 { return tickDt_; } … … 88 97 89 98 private: 90 // !Undefined99 /// Undefined 91 100 Clock(const Clock& instance); 92 101 93 Ogre::Timer* timer_; // !< Ogre timer object94 unsigned long long tickTime_; // !< Currently captured time95 long tickDt_; // !< Delta time in microseconds (cache value)96 float tickDtFloat_; // !< Delta time in seconds (cache value)102 Ogre::Timer* timer_; ///< Ogre timer object 103 unsigned long long tickTime_; ///< Currently captured time 104 long tickDt_; ///< Delta time in microseconds (cache value) 105 float tickDtFloat_; ///< Delta time in seconds (cache value) 97 106 }; 98 107 }
Note: See TracChangeset
for help on using the changeset viewer.