oculus1
diff libovr/Src/Kernel/OVR_Timer.h @ 1:e2f9e4603129
added LibOVR and started a simple vr wrapper.
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Sep 2013 16:14:59 +0300 |
parents | |
children | b069a5c27388 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libovr/Src/Kernel/OVR_Timer.h Sat Sep 14 16:14:59 2013 +0300 1.3 @@ -0,0 +1,1 @@ 1.4 +/************************************************************************************ 1.5 1.6 PublicHeader: OVR 1.7 Filename : OVR_Timer.h 1.8 Content : Provides static functions for precise timing 1.9 Created : September 19, 2012 1.10 Notes : 1.11 1.12 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. 1.13 1.14 Use of this software is subject to the terms of the Oculus license 1.15 agreement provided at the time of installation or download, or which 1.16 otherwise accompanies this software in either electronic or hard copy form. 1.17 1.18 ************************************************************************************/ 1.19 1.20 #ifndef OVR_Timer_h 1.21 #define OVR_Timer_h 1.22 1.23 #include "OVR_Types.h" 1.24 1.25 namespace OVR { 1.26 1.27 //----------------------------------------------------------------------------------- 1.28 // ***** Timer 1.29 1.30 // Timer class defines a family of static functions used for application 1.31 // timing and profiling. 1.32 1.33 class Timer 1.34 { 1.35 public: 1.36 enum { 1.37 MsPerSecond = 1000, // Milliseconds in one second. 1.38 MksPerMs = 1000, // Microseconds in one millisecond. 1.39 MksPerSecond = MsPerSecond * MksPerMs 1.40 }; 1.41 1.42 1.43 // ***** Timing APIs for Application 1.44 // These APIs should be used to guide animation and other program functions 1.45 // that require precision. 1.46 1.47 // Returns ticks in milliseconds, as a 32-bit number. May wrap around every 1.48 // 49.2 days. Use either time difference of two values of GetTicks to avoid 1.49 // wrap-around. GetTicksMs may perform better then GetTicks. 1.50 static UInt32 OVR_STDCALL GetTicksMs(); 1.51 1.52 // GetTicks returns general-purpose high resolution application timer value, 1.53 // measured in microseconds (mks, or 1/1000000 of a second). The actual precision 1.54 // is system-specific and may be much lower, such as 1 ms. 1.55 static UInt64 OVR_STDCALL GetTicks(); 1.56 1.57 1.58 // ***** Profiling APIs. 1.59 // These functions should be used for profiling, but may have system specific 1.60 // artifacts that make them less appropriate for general system use. 1.61 // On Win32, for example these rely on QueryPerformanceConter may have 1.62 // problems with thread-core switching and power modes. 1.63 1.64 // Return a hi-res timer value in mks (1/1000000 of a sec). 1.65 // Generally you want to call this at the start and end of an 1.66 // operation, and pass the difference to 1.67 // TicksToSeconds() to find out how long the operation took. 1.68 static UInt64 OVR_STDCALL GetProfileTicks(); 1.69 1.70 // More convenient zero-based profile timer in seconds. First call initializes 1.71 // the "zero" value; future calls return the difference. Not thread safe for first call. 1.72 // Due to low precision of Double, may malfunction after long runtime. 1.73 static double OVR_STDCALL GetProfileSeconds(); 1.74 1.75 // Get the raw cycle counter value, providing the maximum possible timer resolution. 1.76 static UInt64 OVR_STDCALL GetRawTicks(); 1.77 static UInt64 OVR_STDCALL GetRawFrequency(); 1.78 1.79 1.80 // ***** Tick and time unit conversion. 1.81 1.82 // Convert micro-second ticks value into seconds value. 1.83 static inline double TicksToSeconds(UInt64 ticks) 1.84 { 1.85 return static_cast<double>(ticks) * (1.0 / (double)MksPerSecond); 1.86 } 1.87 // Convert Raw or frequency-unit ticks to seconds based on specified frequency. 1.88 static inline double RawTicksToSeconds(UInt64 rawTicks, UInt64 rawFrequency) 1.89 { 1.90 return static_cast<double>(rawTicks) * rawFrequency; 1.91 } 1.92 1.93 private: 1.94 friend class System; 1.95 // System called during program startup/shutdown. 1.96 static void initializeTimerSystem(); 1.97 static void shutdownTimerSystem(); 1.98 }; 1.99 1.100 1.101 } // Scaleform::Timer 1.102 1.103 #endif 1.104 \ No newline at end of file