win32_time.c
Go to the documentation of this file.
00001 //========================================================================
00002 // GLFW 3.1 Win32 - www.glfw.org
00003 //------------------------------------------------------------------------
00004 // Copyright (c) 2002-2006 Marcus Geelnard
00005 // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
00006 //
00007 // This software is provided 'as-is', without any express or implied
00008 // warranty. In no event will the authors be held liable for any damages
00009 // arising from the use of this software.
00010 //
00011 // Permission is granted to anyone to use this software for any purpose,
00012 // including commercial applications, and to alter it and redistribute it
00013 // freely, subject to the following restrictions:
00014 //
00015 // 1. The origin of this software must not be misrepresented; you must not
00016 //    claim that you wrote the original software. If you use this software
00017 //    in a product, an acknowledgment in the product documentation would
00018 //    be appreciated but is not required.
00019 //
00020 // 2. Altered source versions must be plainly marked as such, and must not
00021 //    be misrepresented as being the original software.
00022 //
00023 // 3. This notice may not be removed or altered from any source
00024 //    distribution.
00025 //
00026 //========================================================================
00027 
00028 #include "internal.h"
00029 
00030 
00031 // Return raw time
00032 //
00033 static unsigned __int64 getRawTime(void)
00034 {
00035     if (_glfw.win32_time.hasPC)
00036     {
00037         unsigned __int64 time;
00038         QueryPerformanceCounter((LARGE_INTEGER*) &time);
00039         return time;
00040     }
00041     else
00042         return (unsigned __int64) _glfw_timeGetTime();
00043 }
00044 
00045 
00049 
00050 // Initialise timer
00051 //
00052 void _glfwInitTimer(void)
00053 {
00054     unsigned __int64 frequency;
00055 
00056     if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
00057     {
00058         _glfw.win32_time.hasPC = GL_TRUE;
00059         _glfw.win32_time.resolution = 1.0 / (double) frequency;
00060     }
00061     else
00062     {
00063         _glfw.win32_time.hasPC = GL_FALSE;
00064         _glfw.win32_time.resolution = 0.001; // winmm resolution is 1 ms
00065     }
00066 
00067     _glfw.win32_time.base = getRawTime();
00068 }
00069 
00070 
00074 
00075 double _glfwPlatformGetTime(void)
00076 {
00077     return (double) (getRawTime() - _glfw.win32_time.base) *
00078         _glfw.win32_time.resolution;
00079 }
00080 
00081 void _glfwPlatformSetTime(double time)
00082 {
00083     _glfw.win32_time.base = getRawTime() -
00084         (unsigned __int64) (time / _glfw.win32_time.resolution);
00085 }
00086 


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Tue Jun 25 2019 19:54:39