mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Use C99 fminf and fmaxf
This commit is contained in:
parent
5a0ab56ed7
commit
bb951b4b71
24
src/init.c
24
src/init.c
@ -246,30 +246,6 @@ int _glfw_max(int a, int b)
|
|||||||
return a > b ? a : b;
|
return a > b ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* _glfw_calloc(size_t count, size_t size)
|
void* _glfw_calloc(size_t count, size_t size)
|
||||||
{
|
{
|
||||||
if (count && size)
|
if (count && size)
|
||||||
|
@ -1438,7 +1438,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] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f);
|
state->axes[i] = fminf(fmaxf(value, -1.f), 1.f);
|
||||||
}
|
}
|
||||||
else if (e->type == _GLFW_JOYSTICK_HATBIT)
|
else if (e->type == _GLFW_JOYSTICK_HATBIT)
|
||||||
{
|
{
|
||||||
|
@ -997,8 +997,6 @@ char** _glfwParseUriList(char* text, int* count);
|
|||||||
char* _glfw_strdup(const char* source);
|
char* _glfw_strdup(const char* source);
|
||||||
int _glfw_min(int a, int b);
|
int _glfw_min(int a, int b);
|
||||||
int _glfw_max(int a, int b);
|
int _glfw_max(int a, int b);
|
||||||
float _glfw_fminf(float a, float b);
|
|
||||||
float _glfw_fmaxf(float a, float b);
|
|
||||||
|
|
||||||
void* _glfw_calloc(size_t count, size_t size);
|
void* _glfw_calloc(size_t count, size_t size);
|
||||||
void* _glfw_realloc(void* pointer, size_t size);
|
void* _glfw_realloc(void* pointer, size_t size);
|
||||||
|
@ -487,7 +487,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
|||||||
// Apply gamma curve
|
// Apply gamma curve
|
||||||
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
|
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
|
||||||
// Clamp to value range
|
// Clamp to value range
|
||||||
value = _glfw_fminf(value, 65535.f);
|
value = fminf(value, 65535.f);
|
||||||
|
|
||||||
values[i] = (unsigned short) value;
|
values[i] = (unsigned short) value;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
|||||||
float value;
|
float value;
|
||||||
value = i / (float) (monitor->null.ramp.size - 1);
|
value = i / (float) (monitor->null.ramp.size - 1);
|
||||||
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
|
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
|
||||||
value = _glfw_fminf(value, 65535.f);
|
value = fminf(value, 65535.f);
|
||||||
|
|
||||||
monitor->null.ramp.red[i] = (unsigned short) value;
|
monitor->null.ramp.red[i] = (unsigned short) value;
|
||||||
monitor->null.ramp.green[i] = (unsigned short) value;
|
monitor->null.ramp.green[i] = (unsigned short) value;
|
||||||
|
Loading…
Reference in New Issue
Block a user