1 /// Translated from C to D 2 module glfw3.win32_time; 3 4 extern(C): @nogc: nothrow: __gshared: 5 //======================================================================== 6 // GLFW 3.3 Win32 - www.glfw.org 7 //------------------------------------------------------------------------ 8 // Copyright (c) 2002-2006 Marcus Geelnard 9 // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> 10 // 11 // This software is provided 'as-is', without any express or implied 12 // warranty. In no event will the authors be held liable for any damages 13 // arising from the use of this software. 14 // 15 // Permission is granted to anyone to use this software for any purpose, 16 // including commercial applications, and to alter it and redistribute it 17 // freely, subject to the following restrictions: 18 // 19 // 1. The origin of this software must not be misrepresented; you must not 20 // claim that you wrote the original software. If you use this software 21 // in a product, an acknowledgment in the product documentation would 22 // be appreciated but is not required. 23 // 24 // 2. Altered source versions must be plainly marked as such, and must not 25 // be misrepresented as being the original software. 26 // 27 // 3. This notice may not be removed or altered from any source 28 // distribution. 29 // 30 //======================================================================== 31 // Please use C89 style variable declarations in this file because VS 2010 32 //======================================================================== 33 34 public import glfw3.internal; 35 36 37 ////////////////////////////////////////////////////////////////////////// 38 ////// GLFW internal API ////// 39 ////////////////////////////////////////////////////////////////////////// 40 41 // Initialise timer 42 // 43 void _glfwInitTimerWin32() { 44 ulong frequency; 45 46 if (QueryPerformanceFrequency(cast(LARGE_INTEGER*) &frequency)) 47 { 48 _glfw.timer.win32.hasPC = GLFW_TRUE; 49 _glfw.timer.win32.frequency = frequency; 50 } 51 else 52 { 53 _glfw.timer.win32.hasPC = GLFW_FALSE; 54 _glfw.timer.win32.frequency = 1000; 55 } 56 } 57 58 59 ////////////////////////////////////////////////////////////////////////// 60 ////// GLFW platform API ////// 61 ////////////////////////////////////////////////////////////////////////// 62 63 ulong _glfwPlatformGetTimerValue() { 64 if (_glfw.timer.win32.hasPC) 65 { 66 ulong value; 67 QueryPerformanceCounter(cast(LARGE_INTEGER*) &value); 68 return value; 69 } 70 else 71 return cast(ulong) _glfw.win32.winmm.GetTime(); 72 } 73 74 ulong _glfwPlatformGetTimerFrequency() { 75 return _glfw.timer.win32.frequency; 76 }