Win32: Fix build on older versions of Visual C++

Older versions did not provide fmin or fmax.  This adds internal
versions of fminf and fmaxf that should not be confused with
standards compliant implementations.
This commit is contained in:
Camilla Löwy 2018-12-18 19:15:29 +01:00
parent 8e313d911b
commit 8c611fd5d0
3 changed files with 27 additions and 1 deletions

View File

@ -119,6 +119,30 @@ char* _glfw_strdup(const char* source)
return result; return result;
} }
float _glfw_fminf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a < b)
return a;
else
return b;
}
float _glfw_fmaxf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a > b)
return a;
else
return b;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW event API ////// ////// GLFW event API //////

View File

@ -1242,7 +1242,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
if (e->type == _GLFW_JOYSTICK_AXIS) if (e->type == _GLFW_JOYSTICK_AXIS)
{ {
const float value = js->axes[e->index] * e->axisScale + e->axisOffset; const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
state->axes[i] = fminf(fmaxf(value, -1.f), 1.f); state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f);
} }
else if (e->type == _GLFW_JOYSTICK_HATBIT) else if (e->type == _GLFW_JOYSTICK_HATBIT)
{ {

View File

@ -766,4 +766,6 @@ void _glfwTerminateVulkan(void);
const char* _glfwGetVulkanResultString(VkResult result); const char* _glfwGetVulkanResultString(VkResult result);
char* _glfw_strdup(const char* source); char* _glfw_strdup(const char* source);
float _glfw_fminf(float a, float b);
float _glfw_fmaxf(float a, float b);