Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_Timer.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 PublicHeader: OVR
4 Filename : OVR_Timer.h
5 Content : Provides static functions for precise timing
6 Created : September 19, 2012
7 Notes :
8 
9 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 
11 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 you may not use the Oculus VR Rift SDK except in compliance with the License,
13 which is provided at the time of installation or download, or which
14 otherwise accompanies this software in either electronic or hard copy form.
15 
16 You may obtain a copy of the License at
17 
18 http://www.oculusvr.com/licenses/LICENSE-3.1
19 
20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 distributed under the License is distributed on an "AS IS" BASIS,
22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 See the License for the specific language governing permissions and
24 limitations under the License.
25 
26 ************************************************************************************/
27 
28 #ifndef OVR_Timer_h
29 #define OVR_Timer_h
30 
31 #include "OVR_Types.h"
32 
33 namespace OVR {
34 
35 //-----------------------------------------------------------------------------------
36 // ***** Timer
37 
38 // Timer class defines a family of static functions used for application
39 // timing and profiling.
40 
41 class Timer
42 {
43 public:
44  enum {
45  MsPerSecond = 1000, // Milliseconds in one second.
46  NanosPerSecond = MsPerSecond * 1000 * 1000,
48  };
49 
50  // ***** Timing APIs for Application
51 
52  // These APIs should be used to guide animation and other program functions
53  // that require precision.
54 
55  // Returns global high-resolution application timer in seconds.
56  static double OVR_STDCALL GetSeconds();
57 
58  // Returns time in Nanoseconds, using highest possible system resolution.
60 
61  // Kept for compatibility.
62  // Returns ticks in milliseconds, as a 32-bit number. May wrap around every 49.2 days.
63  // Use either time difference of two values of GetTicks to avoid wrap-around.
65  { return UInt32(GetTicksNanos() / 1000000); }
66 
67  // for recorded data playback
68  static void SetFakeSeconds(double fakeSeconds)
69  {
70  FakeSeconds = fakeSeconds;
71  useFakeSeconds = true;
72  }
73 
74 private:
75  friend class System;
76  // System called during program startup/shutdown.
77  static void initializeTimerSystem();
78  static void shutdownTimerSystem();
79 
80  // for recorded data playback
81  static double FakeSeconds;
82  static bool useFakeSeconds;
83 };
84 
85 
86 } // OVR::Timer
87 
88 #endif
static UInt64 OVR_STDCALL GetTicksNanos()
Definition: OVR_Timer.cpp:263
uint64_t UInt64
Definition: OVR_Types.h:255
static bool useFakeSeconds
Definition: OVR_Timer.h:82
uint32_t UInt32
Definition: OVR_Types.h:253
#define OVR_STDCALL
static UInt32 OVR_STDCALL GetTicksMs()
Definition: OVR_Timer.h:64
static void SetFakeSeconds(double fakeSeconds)
Definition: OVR_Timer.h:68
static void initializeTimerSystem()
Definition: OVR_Timer.cpp:63
static double FakeSeconds
Definition: OVR_Timer.h:81
static double OVR_STDCALL GetSeconds()
Definition: OVR_Timer.cpp:51
static void shutdownTimerSystem()
Definition: OVR_Timer.cpp:66