mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Win32: Remove timeGetTime fallback for timer
The performance counter API is guaranteed to succeed on Windows XP and later so there is no need for a fallback. This removes our last dependency on winmm.
This commit is contained in:
parent
35f3b58c21
commit
b6834bf2a1
@ -71,17 +71,6 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
|
|||||||
//
|
//
|
||||||
static GLFWbool loadLibraries(void)
|
static GLFWbool loadLibraries(void)
|
||||||
{
|
{
|
||||||
_glfw.win32.winmm.instance = _glfwPlatformLoadModule("winmm.dll");
|
|
||||||
if (!_glfw.win32.winmm.instance)
|
|
||||||
{
|
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
|
||||||
"Win32: Failed to load winmm.dll");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.win32.winmm.GetTime = (PFN_timeGetTime)
|
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.win32.winmm.instance, "timeGetTime");
|
|
||||||
|
|
||||||
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
|
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
|
||||||
if (!_glfw.win32.user32.instance)
|
if (!_glfw.win32.user32.instance)
|
||||||
{
|
{
|
||||||
@ -179,9 +168,6 @@ static void freeLibraries(void)
|
|||||||
if (_glfw.win32.dinput8.instance)
|
if (_glfw.win32.dinput8.instance)
|
||||||
_glfwPlatformFreeModule(_glfw.win32.dinput8.instance);
|
_glfwPlatformFreeModule(_glfw.win32.dinput8.instance);
|
||||||
|
|
||||||
if (_glfw.win32.winmm.instance)
|
|
||||||
_glfwPlatformFreeModule(_glfw.win32.winmm.instance);
|
|
||||||
|
|
||||||
if (_glfw.win32.user32.instance)
|
if (_glfw.win32.user32.instance)
|
||||||
_glfwPlatformFreeModule(_glfw.win32.user32.instance);
|
_glfwPlatformFreeModule(_glfw.win32.user32.instance);
|
||||||
|
|
||||||
|
@ -266,10 +266,6 @@ typedef enum
|
|||||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||||
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||||
|
|
||||||
// winmm.dll function pointer typedefs
|
|
||||||
typedef DWORD (WINAPI * PFN_timeGetTime)(void);
|
|
||||||
#define timeGetTime _glfw.win32.winmm.GetTime
|
|
||||||
|
|
||||||
// xinput.dll function pointer typedefs
|
// xinput.dll function pointer typedefs
|
||||||
typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
|
typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
|
||||||
typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
|
typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
|
||||||
@ -459,11 +455,6 @@ typedef struct _GLFWlibraryWin32
|
|||||||
int rawInputSize;
|
int rawInputSize;
|
||||||
UINT mouseTrailSize;
|
UINT mouseTrailSize;
|
||||||
|
|
||||||
struct {
|
|
||||||
HINSTANCE instance;
|
|
||||||
PFN_timeGetTime GetTime;
|
|
||||||
} winmm;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
PFN_DirectInput8Create Create;
|
PFN_DirectInput8Create Create;
|
||||||
@ -531,7 +522,6 @@ typedef struct _GLFWcursorWin32
|
|||||||
//
|
//
|
||||||
typedef struct _GLFWtimerWin32
|
typedef struct _GLFWtimerWin32
|
||||||
{
|
{
|
||||||
GLFWbool hasPC;
|
|
||||||
uint64_t frequency;
|
uint64_t frequency;
|
||||||
} _GLFWtimerWin32;
|
} _GLFWtimerWin32;
|
||||||
|
|
||||||
|
@ -36,30 +36,14 @@
|
|||||||
|
|
||||||
void _glfwPlatformInitTimer(void)
|
void _glfwPlatformInitTimer(void)
|
||||||
{
|
{
|
||||||
uint64_t frequency;
|
QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency);
|
||||||
|
|
||||||
if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
|
|
||||||
{
|
|
||||||
_glfw.timer.win32.hasPC = GLFW_TRUE;
|
|
||||||
_glfw.timer.win32.frequency = frequency;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_glfw.timer.win32.hasPC = GLFW_FALSE;
|
|
||||||
_glfw.timer.win32.frequency = 1000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerValue(void)
|
uint64_t _glfwPlatformGetTimerValue(void)
|
||||||
{
|
{
|
||||||
if (_glfw.timer.win32.hasPC)
|
uint64_t value;
|
||||||
{
|
QueryPerformanceCounter((LARGE_INTEGER*) &value);
|
||||||
uint64_t value;
|
return value;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return (uint64_t) timeGetTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerFrequency(void)
|
uint64_t _glfwPlatformGetTimerFrequency(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user