win32_time.c
Go to the documentation of this file.
1 //========================================================================
2 // GLFW 3.1 Win32 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2002-2006 Marcus Geelnard
5 // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 // claim that you wrote the original software. If you use this software
17 // in a product, an acknowledgment in the product documentation would
18 // be appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not
21 // be misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source
24 // distribution.
25 //
26 //========================================================================
27 
28 #include "internal.h"
29 
30 
31 // Return raw time
32 //
33 static unsigned __int64 getRawTime(void)
34 {
35  if (_glfw.win32_time.hasPC)
36  {
37  unsigned __int64 time;
38  QueryPerformanceCounter((LARGE_INTEGER*) &time);
39  return time;
40  }
41  else
42  return (unsigned __int64) _glfw_timeGetTime();
43 }
44 
45 
49 
50 // Initialise timer
51 //
52 void _glfwInitTimer(void)
53 {
54  unsigned __int64 frequency;
55 
56  if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
57  {
58  _glfw.win32_time.hasPC = GL_TRUE;
59  _glfw.win32_time.resolution = 1.0 / (double) frequency;
60  }
61  else
62  {
63  _glfw.win32_time.hasPC = GL_FALSE;
64  _glfw.win32_time.resolution = 0.001; // winmm resolution is 1 ms
65  }
66 
67  _glfw.win32_time.base = getRawTime();
68 }
69 
70 
74 
76 {
77  return (double) (getRawTime() - _glfw.win32_time.base) *
78  _glfw.win32_time.resolution;
79 }
80 
81 void _glfwPlatformSetTime(double time)
82 {
83  _glfw.win32_time.base = getRawTime() -
84  (unsigned __int64) (time / _glfw.win32_time.resolution);
85 }
86 
double _glfwPlatformGetTime(void)
Returns the value of the GLFW timer.
Definition: win32_time.c:75
_GLFWlibrary _glfw
All global data protected by _glfwInitialized. This should only be touched after a call to glfwInit t...
static unsigned __int64 getRawTime(void)
Definition: win32_time.c:33
void _glfwPlatformSetTime(double time)
Sets the GLFW timer.
Definition: win32_time.c:81
void _glfwInitTimer(void)
Definition: win32_time.c:52
#define _glfw_timeGetTime


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Fri Mar 13 2020 03:16:18