Build with -Wfloat-conversion + fix all warnings
This commit is contained in:
parent
17c459e384
commit
a919774fe4
38 changed files with 199 additions and 203 deletions
|
@ -59,6 +59,11 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
|||
sdl_target_compile_option_all_languages(${TARGET} "-Wundef")
|
||||
endif()
|
||||
|
||||
check_c_compiler_flag(-Wfloat-conversion HAVE_GCC_WFLOAT_CONVERSION)
|
||||
if(HAVE_GCC_WFLOAT_CONVERSION)
|
||||
sdl_target_compile_option_all_languages(${TARGET} "-Wfloat-conversion")
|
||||
endif()
|
||||
|
||||
check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING)
|
||||
if(HAVE_GCC_NO_STRICT_ALIASING)
|
||||
sdl_target_compile_option_all_languages(${TARGET} "-fno-strict-aliasing")
|
||||
|
|
|
@ -966,8 +966,8 @@ static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec
|
|||
const int thisw = thisspec->width;
|
||||
const int thish = thisspec->height;
|
||||
const float thisaspect = ((float)thisw) / ((float)thish);
|
||||
const float aspectdiff = SDL_fabs(wantaspect - thisaspect);
|
||||
const float diff = SDL_fabs(closestaspect - thisaspect);
|
||||
const float aspectdiff = SDL_fabsf(wantaspect - thisaspect);
|
||||
const float diff = SDL_fabsf(closestaspect - thisaspect);
|
||||
const int diffw = SDL_abs(thisw - wantw);
|
||||
if (diff < epsilon) { // matches current closestaspect? See if resolution is closer in size.
|
||||
if (diffw < closestdiffw) {
|
||||
|
@ -1022,7 +1022,7 @@ static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec
|
|||
}
|
||||
|
||||
const float thisfps = thisspec->interval_denominator ? (thisspec->interval_numerator / thisspec->interval_denominator) : 0.0f;
|
||||
const float fpsdiff = SDL_fabs(wantfps - thisfps);
|
||||
const float fpsdiff = SDL_fabsf(wantfps - thisfps);
|
||||
if (fpsdiff < closestfps) { // this is a closest FPS? Take it until something closer arrives.
|
||||
closestfps = fpsdiff;
|
||||
closest->interval_numerator = thisspec->interval_numerator;
|
||||
|
|
|
@ -688,7 +688,7 @@ static int SDL_SYS_ToDirection(Uint16 *dest, const SDL_HapticDirection *src)
|
|||
} else if (!src->dir[0]) {
|
||||
*dest = (src->dir[1] >= 0 ? 0x8000 : 0);
|
||||
} else {
|
||||
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||
float f = SDL_atan2f(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||
/*
|
||||
SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
|
||||
- Y-axis-value is the second coordinate (from center to SOUTH)
|
||||
|
|
|
@ -1252,14 +1252,14 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||
GCControllerDirectionPad *dpad;
|
||||
|
||||
dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadOne];
|
||||
if (dpad.xAxis.value || dpad.yAxis.value) {
|
||||
if (dpad.xAxis.value != 0.f || dpad.yAxis.value != 0.f) {
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
|
||||
} else {
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0, SDL_RELEASED, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadTwo];
|
||||
if (dpad.xAxis.value || dpad.yAxis.value) {
|
||||
if (dpad.xAxis.value != 0.f || dpad.yAxis.value != 0.f) {
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f);
|
||||
} else {
|
||||
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 1, SDL_RELEASED, 0.0f, 0.0f, 1.0f);
|
||||
|
|
|
@ -206,7 +206,7 @@ static SDL_bool GetHIDScaledCalibratedState(recDevice *pDevice, recElement *pEle
|
|||
if (readScale == 0) {
|
||||
returnValue = SDL_TRUE; /* no scaling at all */
|
||||
} else {
|
||||
*pValue = ((*pValue - pElement->minReport) * deviceScale / readScale) + min;
|
||||
*pValue = (Sint32)(((*pValue - pElement->minReport) * deviceScale / readScale) + min);
|
||||
returnValue = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,29 +41,23 @@ static const enum PspCtrlButtons button_map[] = {
|
|||
};
|
||||
static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} point;
|
||||
|
||||
/* 4 points define the bezier-curve. */
|
||||
static point a = { 0, 0 };
|
||||
static point b = { 50, 0 };
|
||||
static point c = { 78, 32767 };
|
||||
static point d = { 128, 32767 };
|
||||
static SDL_Point a = { 0, 0 };
|
||||
static SDL_Point b = { 50, 0 };
|
||||
static SDL_Point c = { 78, 32767 };
|
||||
static SDL_Point d = { 128, 32767 };
|
||||
|
||||
/* simple linear interpolation between two points */
|
||||
static SDL_INLINE void lerp(point *dest, point *pt_a, point *pt_b, float t)
|
||||
static SDL_INLINE void lerp(SDL_Point *dest, const SDL_Point *pt_a, const SDL_Point *pt_b, float t)
|
||||
{
|
||||
dest->x = pt_a->x + (pt_b->x - pt_a->x) * t;
|
||||
dest->y = pt_a->y + (pt_b->y - pt_a->y) * t;
|
||||
dest->x = pt_a->x + (int)((pt_b->x - pt_a->x) * t);
|
||||
dest->y = pt_a->y + (int)((pt_b->y - pt_a->y) * t);
|
||||
}
|
||||
|
||||
/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */
|
||||
static int calc_bezier_y(float t)
|
||||
{
|
||||
point ab, bc, cd, abbc, bccd, dest;
|
||||
SDL_Point ab, bc, cd, abbc, bccd, dest;
|
||||
lerp(&ab, &a, &b, t); /* point between a and b */
|
||||
lerp(&bc, &b, &c, t); /* point between b and c */
|
||||
lerp(&cd, &c, &d, t); /* point between c and d */
|
||||
|
|
|
@ -64,30 +64,24 @@ static const unsigned int ext_button_map[] = {
|
|||
|
||||
static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} point;
|
||||
|
||||
/* 4 points define the bezier-curve. */
|
||||
/* The Vita has a good amount of analog travel, so use a linear curve */
|
||||
static point a = { 0, 0 };
|
||||
static point b = { 0, 0 };
|
||||
static point c = { 128, 32767 };
|
||||
static point d = { 128, 32767 };
|
||||
static SDL_Point a = { 0, 0 };
|
||||
static SDL_Point b = { 0, 0 };
|
||||
static SDL_Point c = { 128, 32767 };
|
||||
static SDL_Point d = { 128, 32767 };
|
||||
|
||||
/* simple linear interpolation between two points */
|
||||
static SDL_INLINE void lerp(point *dest, point *first, point *second, float t)
|
||||
static SDL_INLINE void lerp(SDL_Point *dest, const SDL_Point *first, const SDL_Point *second, float t)
|
||||
{
|
||||
dest->x = first->x + (second->x - first->x) * t;
|
||||
dest->y = first->y + (second->y - first->y) * t;
|
||||
dest->x = first->x + (int)((second->x - first->x) * t);
|
||||
dest->y = first->y + (int)((second->y - first->y) * t);
|
||||
}
|
||||
|
||||
/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */
|
||||
static int calc_bezier_y(float t)
|
||||
{
|
||||
point ab, bc, cd, abbc, bccd, dest;
|
||||
SDL_Point ab, bc, cd, abbc, bccd, dest;
|
||||
lerp(&ab, &a, &b, t); /* point between a and b */
|
||||
lerp(&bc, &b, &c, t); /* point between b and c */
|
||||
lerp(&cd, &c, &d, t); /* point between c and d */
|
||||
|
|
|
@ -43,13 +43,14 @@ SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *p
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (batteryState.charging)
|
||||
if (batteryState.charging) {
|
||||
*state = batteryState.chargingTime == 0.0 ? SDL_POWERSTATE_CHARGED : SDL_POWERSTATE_CHARGING;
|
||||
else
|
||||
} else {
|
||||
*state = SDL_POWERSTATE_ON_BATTERY;
|
||||
}
|
||||
|
||||
*seconds = batteryState.dischargingTime;
|
||||
*percent = batteryState.level * 100;
|
||||
*seconds = (int)batteryState.dischargingTime;
|
||||
*percent = (int)batteryState.level * 100;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
|
|
@ -1047,8 +1047,8 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const
|
|||
viewport->w, viewport->h);
|
||||
if (viewport->w && viewport->h) {
|
||||
data->glOrtho((GLdouble)0, (GLdouble)viewport->w,
|
||||
(GLdouble)istarget ? 0 : viewport->h,
|
||||
(GLdouble)istarget ? viewport->h : 0,
|
||||
(GLdouble)(istarget ? 0 : viewport->h),
|
||||
(GLdouble)(istarget ? viewport->h : 0),
|
||||
0.0, 1.0);
|
||||
}
|
||||
data->glMatrixMode(GL_MODELVIEW);
|
||||
|
|
|
@ -128,10 +128,8 @@ typedef struct
|
|||
float x, y, z;
|
||||
} VertTCV;
|
||||
|
||||
#define PI 3.14159265358979f
|
||||
|
||||
#define radToDeg(x) ((x)*180.f / PI)
|
||||
#define degToRad(x) ((x)*PI / 180.f)
|
||||
#define radToDeg(x) ((x)*180.f / SDL_PI_F)
|
||||
#define degToRad(x) ((x)*SDL_PI_F / 180.f)
|
||||
|
||||
static float MathAbs(float x)
|
||||
{
|
||||
|
@ -809,7 +807,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
|
|||
float curX = x;
|
||||
const float endX = x + width;
|
||||
const float slice = 64.0f;
|
||||
const size_t count = SDL_ceilf(width / slice);
|
||||
const size_t count = (size_t)SDL_ceilf(width / slice);
|
||||
size_t i;
|
||||
float ustep = (u1 - u0) / width * slice;
|
||||
|
||||
|
@ -877,7 +875,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T
|
|||
|
||||
cmd->data.draw.count = 1;
|
||||
|
||||
MathSincos(degToRad(360 - angle), &s, &c);
|
||||
MathSincos(degToRad((float)(360 - angle)), &s, &c);
|
||||
|
||||
cw1 = c * -centerx;
|
||||
sw1 = s * -centerx;
|
||||
|
|
|
@ -838,8 +838,8 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
|||
if (data->drawstate.viewport_dirty) {
|
||||
const SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
|
||||
float sw = viewport->w / 2.;
|
||||
float sh = viewport->h / 2.;
|
||||
float sw = viewport->w / 2.f;
|
||||
float sh = viewport->h / 2.f;
|
||||
|
||||
float x_scale = sw;
|
||||
float x_off = viewport->x + sw;
|
||||
|
|
|
@ -1367,7 +1367,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
|
|||
if (state->window_maxW || state->window_maxH) {
|
||||
SDL_SetWindowMaximumSize(state->windows[i], state->window_maxW, state->window_maxH);
|
||||
}
|
||||
if (state->window_min_aspect || state->window_max_aspect) {
|
||||
if (state->window_min_aspect != 0.f || state->window_max_aspect != 0.f) {
|
||||
SDL_SetWindowAspectRatio(state->windows[i], state->window_min_aspect, state->window_max_aspect);
|
||||
}
|
||||
SDL_GetWindowSize(state->windows[i], &w, &h);
|
||||
|
|
|
@ -796,7 +796,7 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
|
|||
if (tonemap_operator) {
|
||||
if (SDL_strncmp(tonemap_operator, "*=", 2) == 0) {
|
||||
tonemap.op = SDL_TONEMAP_LINEAR;
|
||||
tonemap.data.linear.scale = SDL_atof(tonemap_operator + 2);
|
||||
tonemap.data.linear.scale = (float)SDL_atof(tonemap_operator + 2);
|
||||
} else if (SDL_strcasecmp(tonemap_operator, "chrome") == 0) {
|
||||
tonemap.op = SDL_TONEMAP_CHROME;
|
||||
} else if (SDL_strcasecmp(tonemap_operator, "none") == 0) {
|
||||
|
|
|
@ -1497,8 +1497,8 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
|
|||
if (focus && ([theEvent window] == ((__bridge SDL_CocoaWindowData *)focus->driverdata).nswindow)) {
|
||||
rc = SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, state, button, clicks);
|
||||
} else {
|
||||
const int orig_x = mouse->x;
|
||||
const int orig_y = mouse->y;
|
||||
const float orig_x = mouse->x;
|
||||
const float orig_y = mouse->y;
|
||||
const NSPoint point = [theEvent locationInWindow];
|
||||
mouse->x = (int)point.x;
|
||||
mouse->y = (int)(window->h - point.y);
|
||||
|
@ -2376,8 +2376,8 @@ void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int
|
|||
viewport = [contentView convertRectToBacking:viewport];
|
||||
}
|
||||
|
||||
*w = viewport.size.width;
|
||||
*h = viewport.size.height;
|
||||
*w = (int)viewport.size.width;
|
||||
*h = (int)viewport.size.height;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -886,7 +886,7 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u
|
|||
emscripten_get_element_css_size(window_data->canvas_id, &w, &h);
|
||||
}
|
||||
|
||||
emscripten_set_canvas_element_size(window_data->canvas_id, w * window_data->pixel_ratio, h * window_data->pixel_ratio);
|
||||
emscripten_set_canvas_element_size(window_data->canvas_id, SDL_lroundf(w * window_data->pixel_ratio), SDL_lroundf(h * window_data->pixel_ratio));
|
||||
|
||||
/* set_canvas_size unsets this */
|
||||
if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
|
||||
|
@ -899,7 +899,7 @@ static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *u
|
|||
window_data->window->h = 0;
|
||||
}
|
||||
|
||||
SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, w, h);
|
||||
SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(w), SDL_lroundf(h));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -915,7 +915,7 @@ Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userDat
|
|||
if (window_data->fullscreen_resize) {
|
||||
double css_w, css_h;
|
||||
emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h);
|
||||
SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, css_w, css_h);
|
||||
SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(css_w), SDL_lroundf(css_h));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -215,9 +215,9 @@ static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, S
|
|||
scaled_w = css_w * wdata->pixel_ratio;
|
||||
scaled_h = css_h * wdata->pixel_ratio;
|
||||
|
||||
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, css_w, css_h);
|
||||
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(css_w), SDL_lroundf(css_h));
|
||||
}
|
||||
emscripten_set_canvas_element_size(wdata->canvas_id, scaled_w, scaled_h);
|
||||
emscripten_set_canvas_element_size(wdata->canvas_id, SDL_lroundf(scaled_w), SDL_lroundf(scaled_h));
|
||||
|
||||
/* if the size is not being controlled by css, we need to scale down for hidpi */
|
||||
if (!wdata->external_size) {
|
||||
|
@ -252,7 +252,7 @@ static void Emscripten_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
|
||||
data->pixel_ratio = emscripten_get_device_pixel_ratio();
|
||||
}
|
||||
emscripten_set_canvas_element_size(data->canvas_id, window->floating.w * data->pixel_ratio, window->floating.h * data->pixel_ratio);
|
||||
emscripten_set_canvas_element_size(data->canvas_id, SDL_lroundf(window->floating.w * data->pixel_ratio), SDL_lroundf(window->floating.h * data->pixel_ratio));
|
||||
|
||||
/*scale canvas down*/
|
||||
if (!data->external_size && data->pixel_ratio != 1.0f) {
|
||||
|
@ -268,8 +268,8 @@ static void Emscripten_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window
|
|||
SDL_WindowData *data;
|
||||
if (window->driverdata) {
|
||||
data = window->driverdata;
|
||||
*w = window->w * data->pixel_ratio;
|
||||
*h = window->h * data->pixel_ratio;
|
||||
*w = SDL_lroundf(window->w * data->pixel_ratio);
|
||||
*h = SDL_lroundf(window->h * data->pixel_ratio);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -422,7 +422,7 @@ static int KMSDRM_MoveCursor(SDL_Cursor *cursor)
|
|||
return SDL_SetError("Cursor not initialized properly.");
|
||||
}
|
||||
|
||||
ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y);
|
||||
ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, (int)mouse->x, (int)mouse->y);
|
||||
|
||||
if (ret) {
|
||||
return SDL_SetError("drmModeMoveCursor() failed.");
|
||||
|
|
|
@ -366,7 +366,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
|||
new_mode_parameters.visibleRegion.height = window->h;
|
||||
/* SDL (and DRM, if we look at drmModeModeInfo vrefresh) uses plain integer Hz for
|
||||
display mode refresh rate, but Vulkan expects higher precision. */
|
||||
new_mode_parameters.refreshRate = window->current_fullscreen_mode.refresh_rate * 1000;
|
||||
new_mode_parameters.refreshRate = (uint32_t)(window->current_fullscreen_mode.refresh_rate * 1000);
|
||||
|
||||
SDL_zero(display_mode_create_info);
|
||||
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
|
||||
|
|
|
@ -386,8 +386,8 @@ int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
|
|||
|
||||
for (UIScreenMode *uimode in availableModes) {
|
||||
CGSize size = GetUIScreenModeSize(data.uiscreen, uimode);
|
||||
int w = size.width;
|
||||
int h = size.height;
|
||||
int w = (int)size.width;
|
||||
int h = (int)size.height;
|
||||
|
||||
/* Make sure the width/height are oriented correctly */
|
||||
if (isLandscape != (w > h)) {
|
||||
|
@ -449,10 +449,10 @@ int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ
|
|||
return -1;
|
||||
}
|
||||
|
||||
rect->x += frame.origin.x;
|
||||
rect->y += frame.origin.y;
|
||||
rect->w = frame.size.width;
|
||||
rect->h = frame.size.height;
|
||||
rect->x += (int)frame.origin.x;
|
||||
rect->y += (int)frame.origin.y;
|
||||
rect->w = (int)frame.size.width;
|
||||
rect->h = (int)frame.size.height;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -522,8 +522,8 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
|
|||
#endif
|
||||
|
||||
if (self.keyboardHeight) {
|
||||
int rectbottom = self.textInputRect.y + self.textInputRect.h;
|
||||
int keybottom = self.view.bounds.size.height - self.keyboardHeight;
|
||||
int rectbottom = (int)(self.textInputRect.y + self.textInputRect.h);
|
||||
int keybottom = (int)(self.view.bounds.size.height - self.keyboardHeight);
|
||||
if (keybottom < rectbottom) {
|
||||
offset.y = keybottom - rectbottom;
|
||||
}
|
||||
|
|
|
@ -376,8 +376,8 @@ void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int
|
|||
|
||||
/* Integer truncation of fractional values matches SDL_uikitmetalview and
|
||||
* SDL_uikitopenglview. */
|
||||
*w = size.width * scale;
|
||||
*h = size.height * scale;
|
||||
*w = (int)(size.width * scale);
|
||||
*h = (int)(size.height * scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,11 +173,11 @@ void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita
|
|||
y = (vita_y - area_info[port].y) / (area_info[port].h - 1);
|
||||
}
|
||||
|
||||
x = SDL_max(x, 0.0);
|
||||
x = SDL_min(x, 1.0);
|
||||
x = SDL_max(x, 0.0f);
|
||||
x = SDL_min(x, 1.0f);
|
||||
|
||||
y = SDL_max(y, 0.0);
|
||||
y = SDL_min(y, 1.0);
|
||||
y = SDL_max(y, 0.0f);
|
||||
y = SDL_min(y, 1.0f);
|
||||
|
||||
*sdl_x = x;
|
||||
*sdl_y = y;
|
||||
|
|
|
@ -998,12 +998,12 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri
|
|||
if (window_data->current.logical_width <= 1) {
|
||||
x = 0.5f;
|
||||
} else {
|
||||
x = wl_fixed_to_double(fx) / (window_data->current.logical_width - 1);
|
||||
x = (float)wl_fixed_to_double(fx) / (window_data->current.logical_width - 1);
|
||||
}
|
||||
if (window_data->current.logical_height <= 1) {
|
||||
y = 0.5f;
|
||||
} else {
|
||||
y = wl_fixed_to_double(fy) / (window_data->current.logical_height - 1);
|
||||
y = (float)wl_fixed_to_double(fy) / (window_data->current.logical_height - 1);
|
||||
}
|
||||
|
||||
SDL_SetMouseFocus(window_data->sdlwindow);
|
||||
|
@ -1026,8 +1026,8 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial
|
|||
SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
|
||||
|
||||
if (window_data) {
|
||||
const float x = wl_fixed_to_double(fx) / window_data->current.logical_width;
|
||||
const float y = wl_fixed_to_double(fy) / window_data->current.logical_height;
|
||||
const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width;
|
||||
const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height;
|
||||
|
||||
SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
|
||||
(SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_FALSE, x, y, 0.0f);
|
||||
|
@ -1055,8 +1055,8 @@ static void touch_handler_motion(void *data, struct wl_touch *touch, uint32_t ti
|
|||
SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
|
||||
|
||||
if (window_data) {
|
||||
const float x = wl_fixed_to_double(fx) / window_data->current.logical_width;
|
||||
const float y = wl_fixed_to_double(fy) / window_data->current.logical_height;
|
||||
const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width;
|
||||
const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height;
|
||||
|
||||
SDL_SendTouchMotion(Wayland_GetPointerTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
|
||||
(SDL_FingerID)(id + 1), window_data->sdlwindow, x, y, 1.0f);
|
||||
|
@ -2783,7 +2783,7 @@ static void tablet_tool_handle_slider(void *data, struct zwp_tablet_tool_v2 *too
|
|||
{
|
||||
struct SDL_WaylandTool *sdltool = data;
|
||||
struct SDL_WaylandTabletInput *input = sdltool->tablet;
|
||||
input->current_pen.update_status.axes[SDL_PEN_AXIS_SLIDER] = position / 65535.0;
|
||||
input->current_pen.update_status.axes[SDL_PEN_AXIS_SLIDER] = position / 65535.f;
|
||||
}
|
||||
|
||||
static void tablet_tool_handle_wheel(void *data, struct zwp_tablet_tool_v2 *tool, int32_t degrees, int32_t clicks)
|
||||
|
|
|
@ -350,7 +350,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, struct Wayland_C
|
|||
|
||||
/* Cursors use integer scaling. */
|
||||
*scale = SDL_ceilf(focusdata->windowed_scale_factor);
|
||||
size *= *scale;
|
||||
size *= (int)*scale;
|
||||
for (int i = 0; i < vdata->num_cursor_themes; i += 1) {
|
||||
if (vdata->cursor_themes[i].size == size) {
|
||||
theme = vdata->cursor_themes[i].theme;
|
||||
|
@ -638,12 +638,12 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor)
|
|||
}
|
||||
}
|
||||
|
||||
wl_surface_set_buffer_scale(data->surface, scale);
|
||||
wl_surface_set_buffer_scale(data->surface, (int32_t)scale);
|
||||
wl_pointer_set_cursor(pointer,
|
||||
input->pointer_enter_serial,
|
||||
data->surface,
|
||||
data->hot_x / scale,
|
||||
data->hot_y / scale);
|
||||
(int32_t)(data->hot_x / scale),
|
||||
(int32_t)(data->hot_y / scale));
|
||||
if (data->is_system_cursor) {
|
||||
wl_surface_attach(data->surface, data->cursor_data.system.frames[0].wl_buffer, 0, 0);
|
||||
|
||||
|
|
|
@ -846,10 +846,10 @@ static void handle_configure_xdg_toplevel(void *data,
|
|||
/* Aspect correction. */
|
||||
const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height;
|
||||
|
||||
if (window->min_aspect && aspect < window->min_aspect) {
|
||||
wind->requested.logical_height = SDL_roundf((float)wind->requested.logical_width / window->min_aspect);
|
||||
} else if (window->max_aspect && aspect > window->max_aspect) {
|
||||
wind->requested.logical_width = SDL_roundf((float)wind->requested.logical_height * window->max_aspect);
|
||||
if (window->min_aspect != 0.f && aspect < window->min_aspect) {
|
||||
wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect);
|
||||
} else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
|
||||
wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect);
|
||||
}
|
||||
} else {
|
||||
if (window->max_w > 0) {
|
||||
|
@ -865,10 +865,10 @@ static void handle_configure_xdg_toplevel(void *data,
|
|||
/* Aspect correction. */
|
||||
const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height;
|
||||
|
||||
if (window->min_aspect && aspect < window->min_aspect) {
|
||||
wind->requested.pixel_height = SDL_roundf((float)wind->requested.pixel_width / window->min_aspect);
|
||||
} else if (window->max_aspect && aspect > window->max_aspect) {
|
||||
wind->requested.pixel_width = SDL_roundf((float)wind->requested.pixel_height * window->max_aspect);
|
||||
if (window->min_aspect != 0.f && aspect < window->min_aspect) {
|
||||
wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect);
|
||||
} else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
|
||||
wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect);
|
||||
}
|
||||
|
||||
wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width);
|
||||
|
@ -1228,10 +1228,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
|
|||
/* Aspect correction. */
|
||||
const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height;
|
||||
|
||||
if (window->min_aspect && aspect < window->min_aspect) {
|
||||
wind->requested.logical_height = SDL_roundf((float)wind->requested.logical_width / window->min_aspect);
|
||||
} else if (window->max_aspect && aspect > window->max_aspect) {
|
||||
wind->requested.logical_width = SDL_roundf((float)wind->requested.logical_height * window->max_aspect);
|
||||
if (window->min_aspect != 0.f && aspect < window->min_aspect) {
|
||||
wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect);
|
||||
} else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
|
||||
wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect);
|
||||
}
|
||||
} else {
|
||||
if (window->max_w > 0) {
|
||||
|
@ -1247,10 +1247,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
|
|||
/* Aspect correction. */
|
||||
const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height;
|
||||
|
||||
if (window->min_aspect && aspect < window->min_aspect) {
|
||||
wind->requested.pixel_height = SDL_roundf((float)wind->requested.pixel_width / window->min_aspect);
|
||||
} else if (window->max_aspect && aspect > window->max_aspect) {
|
||||
wind->requested.pixel_width = SDL_roundf((float)wind->requested.pixel_height * window->max_aspect);
|
||||
if (window->min_aspect != 0.f && aspect < window->min_aspect) {
|
||||
wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect);
|
||||
} else if (window->max_aspect != 0.f && aspect > window->max_aspect) {
|
||||
wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect);
|
||||
}
|
||||
|
||||
wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width);
|
||||
|
@ -1471,7 +1471,7 @@ static const struct wl_surface_listener surface_listener = {
|
|||
|
||||
static void handle_preferred_fractional_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale)
|
||||
{
|
||||
const float factor = scale / 120.; /* 120 is a magic number defined in the spec as a common denominator */
|
||||
const float factor = scale / 120.f; /* 120 is a magic number defined in the spec as a common denominator */
|
||||
Wayland_HandlePreferredScaleChanged(data, factor);
|
||||
}
|
||||
|
||||
|
|
|
@ -570,7 +570,7 @@ SDL_bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const
|
|||
{
|
||||
SDL_Window *window = data->window;
|
||||
if (!window->hit_test) return SDL_FALSE;
|
||||
const SDL_Point point = { x, y };
|
||||
const SDL_Point point = { (int)x, (int)y };
|
||||
SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
|
||||
if (!force_new_result && rc == data->hit_test_result) {
|
||||
return SDL_TRUE;
|
||||
|
@ -585,7 +585,7 @@ SDL_bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data,
|
|||
SDL_Window *window = data->window;
|
||||
|
||||
if (window->hit_test) {
|
||||
const SDL_Point point = { x, y };
|
||||
const SDL_Point point = { (int)x, (int)y };
|
||||
static const int directions[] = {
|
||||
_NET_WM_MOVERESIZE_SIZE_TOPLEFT, _NET_WM_MOVERESIZE_SIZE_TOP,
|
||||
_NET_WM_MOVERESIZE_SIZE_TOPRIGHT, _NET_WM_MOVERESIZE_SIZE_RIGHT,
|
||||
|
|
|
@ -152,7 +152,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
|
|||
|
||||
if (new_scale > 0.0) {
|
||||
*scale_factor = new_scale;
|
||||
UpdateDisplayContentScale(new_scale);
|
||||
UpdateDisplayContentScale((float)new_scale);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
|
@ -245,7 +245,7 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this)
|
|||
}
|
||||
}
|
||||
|
||||
return scale_factor;
|
||||
return (float)scale_factor;
|
||||
}
|
||||
|
||||
static int get_visualinfo(Display *display, int screen, XVisualInfo *vinfo)
|
||||
|
@ -402,7 +402,7 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor)
|
|||
|
||||
static float CalculateXRandRRefreshRate(const XRRModeInfo *info)
|
||||
{
|
||||
double vTotal = info->vTotal;
|
||||
float vTotal = info->vTotal;
|
||||
|
||||
if (info->modeFlags & RR_DoubleScan) {
|
||||
/* doublescan doubles the number of lines */
|
||||
|
@ -415,7 +415,7 @@ static float CalculateXRandRRefreshRate(const XRRModeInfo *info)
|
|||
vTotal /= 2;
|
||||
}
|
||||
|
||||
if (info->hTotal && vTotal) {
|
||||
if (info->hTotal && vTotal != 0.f) {
|
||||
return ((100 * (Sint64)info->dotClock) / (info->hTotal * vTotal)) / 100.0f;
|
||||
}
|
||||
return 0.0f;
|
||||
|
|
|
@ -481,8 +481,8 @@ void X11_InitPen(SDL_VideoDevice *_this)
|
|||
Atom vname = val_classinfo->label;
|
||||
int axis = -1;
|
||||
|
||||
float min = val_classinfo->min;
|
||||
float max = val_classinfo->max;
|
||||
float min = (float)val_classinfo->min;
|
||||
float max = (float)val_classinfo->max;
|
||||
|
||||
if (vname == pen_atoms.abs_pressure) {
|
||||
axis = SDL_PEN_AXIS_PRESSURE;
|
||||
|
@ -653,7 +653,7 @@ static void xinput2_normalize_pen_axes(const SDL_Pen *peninfo,
|
|||
|
||||
case SDL_PEN_AXIS_ROTATION:
|
||||
/* normalised to -1..1, so let's convert to degrees */
|
||||
value *= 180.0;
|
||||
value *= 180.0f;
|
||||
value += xpen->rotation_bias;
|
||||
|
||||
/* handle simple over/underflow */
|
||||
|
@ -685,7 +685,7 @@ void X11_PenAxesFromValuators(const SDL_Pen *peninfo,
|
|||
if (valuator == SDL_PEN_AXIS_VALUATOR_MISSING || valuator >= mask_len * 8 || !(XIMaskIsSet(mask, valuator))) {
|
||||
axis_values[i] = 0.0f;
|
||||
} else {
|
||||
axis_values[i] = input_values[valuator];
|
||||
axis_values[i] = (float)input_values[valuator];
|
||||
}
|
||||
}
|
||||
xinput2_normalize_pen_axes(peninfo, pen, axis_values);
|
||||
|
|
|
@ -102,17 +102,17 @@ static void xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x,
|
|||
if (window->w == 1) {
|
||||
*out_x = 0.5f;
|
||||
} else {
|
||||
*out_x = in_x / (window->w - 1);
|
||||
*out_x = (float)in_x / (window->w - 1);
|
||||
}
|
||||
if (window->h == 1) {
|
||||
*out_y = 0.5f;
|
||||
} else {
|
||||
*out_y = in_y / (window->h - 1);
|
||||
*out_y = (float)in_y / (window->h - 1);
|
||||
}
|
||||
} else {
|
||||
// couldn't find the window...
|
||||
*out_x = in_x;
|
||||
*out_y = in_y;
|
||||
*out_x = (float)in_x;
|
||||
*out_y = (float)in_y;
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
|
||||
|
@ -400,10 +400,10 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
|||
xevent.xkey.root = xev->root;
|
||||
xevent.xkey.subwindow = xev->child;
|
||||
xevent.xkey.time = xev->time;
|
||||
xevent.xkey.x = xev->event_x;
|
||||
xevent.xkey.y = xev->event_y;
|
||||
xevent.xkey.x_root = xev->root_x;
|
||||
xevent.xkey.y_root = xev->root_y;
|
||||
xevent.xkey.x = (int)xev->event_x;
|
||||
xevent.xkey.y = (int)xev->event_y;
|
||||
xevent.xkey.x_root = (int)xev->root_x;
|
||||
xevent.xkey.y_root = (int)xev->root_y;
|
||||
xevent.xkey.state = xev->mods.effective;
|
||||
xevent.xkey.keycode = xev->detail;
|
||||
xevent.xkey.same_screen = 1;
|
||||
|
@ -463,7 +463,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
|||
|
||||
if (pressed) {
|
||||
X11_HandleButtonPress(_this, windowdata, (SDL_MouseID)xev->sourceid, button,
|
||||
xev->event_x, xev->event_y, xev->time);
|
||||
(float)xev->event_x, (float)xev->event_y, xev->time);
|
||||
} else {
|
||||
X11_HandleButtonRelease(_this, windowdata, (SDL_MouseID)xev->sourceid, button);
|
||||
}
|
||||
|
@ -492,8 +492,8 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
|||
if (pen) {
|
||||
SDL_PenStatusInfo pen_status;
|
||||
|
||||
pen_status.x = xev->event_x;
|
||||
pen_status.y = xev->event_y;
|
||||
pen_status.x = (float)xev->event_x;
|
||||
pen_status.y = (float)xev->event_y;
|
||||
|
||||
X11_PenAxesFromValuators(pen,
|
||||
xev->valuators.values, xev->valuators.mask, xev->valuators.mask_len,
|
||||
|
|
|
@ -1059,11 +1059,11 @@ static int audio_resampleLoss(void *arg)
|
|||
}
|
||||
SDL_free(buf_out);
|
||||
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
|
||||
SDLTest_AssertCheck(isfinite(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(isfinite(sum_squared_error), "Sum of squared error should be finite.");
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite.");
|
||||
/* Infinity is theoretically possible when there is very little to no noise */
|
||||
SDLTest_AssertCheck(!isnan(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
|
||||
SDLTest_AssertCheck(isfinite(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
|
||||
SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(signal_to_noise >= spec->signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.",
|
||||
signal_to_noise, spec->signal_to_noise);
|
||||
SDLTest_AssertCheck(max_error <= spec->max_error, "Maximum conversion error %f should be no more than %f.",
|
||||
|
@ -1345,11 +1345,11 @@ static int audio_formatChange(void *arg)
|
|||
}
|
||||
|
||||
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
|
||||
SDLTest_AssertCheck(isfinite(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(isfinite(sum_squared_error), "Sum of squared error should be finite.");
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite.");
|
||||
/* Infinity is theoretically possible when there is very little to no noise */
|
||||
SDLTest_AssertCheck(!isnan(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
|
||||
SDLTest_AssertCheck(isfinite(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
|
||||
SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(signal_to_noise >= target_signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.",
|
||||
signal_to_noise, target_signal_to_noise);
|
||||
SDLTest_AssertCheck(max_error <= target_max_error, "Maximum conversion error %f should be no more than %f.",
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#define EULER M_E
|
||||
#endif
|
||||
|
||||
#define IS_INFINITY(V) isinf(V)
|
||||
#define IS_INFINITY(V) ISINF(V)
|
||||
|
||||
/* Square root of 3 (used in atan2) */
|
||||
#define SQRT3 1.7320508075688771931766041234368458390235900878906250
|
||||
|
@ -207,7 +207,7 @@ helper_range(const char *func_name, d_to_d_func func)
|
|||
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
|
||||
double result;
|
||||
/* These are tested elsewhere */
|
||||
if (isnan(test_value) || isinf(test_value)) {
|
||||
if (ISNAN(test_value) || ISINF(test_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ static int
|
|||
floor_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_floor(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Floor(nan), expected nan, got %f",
|
||||
result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -376,7 +376,7 @@ static int
|
|||
ceil_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_ceil(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Ceil(nan), expected nan, got %f",
|
||||
result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -480,7 +480,7 @@ static int
|
|||
trunc_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_trunc(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Trunc(nan), expected nan, got %f",
|
||||
result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -584,7 +584,7 @@ static int
|
|||
round_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_round(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Round(nan), expected nan, got %f",
|
||||
result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -688,7 +688,7 @@ static int
|
|||
fabs_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_fabs(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fabs(nan), expected nan, got %f",
|
||||
result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -765,12 +765,12 @@ copysign_nanCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_copysign(NAN, 1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Copysign(nan,1.0), expected nan, got %f",
|
||||
result);
|
||||
|
||||
result = SDL_copysign(NAN, -1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Copysign(nan,-1.0), expected nan, got %f",
|
||||
result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -793,7 +793,7 @@ copysign_rangeTest(void *args)
|
|||
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
|
||||
double result;
|
||||
/* These are tested elsewhere */
|
||||
if (isnan(test_value) || isinf(test_value)) {
|
||||
if (ISNAN(test_value) || ISINF(test_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -829,22 +829,22 @@ fmod_divOfInfCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_fmod(INFINITY, -1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(%f,%.1f), expected %f, got %f",
|
||||
INFINITY, -1.0, NAN, result);
|
||||
|
||||
result = SDL_fmod(INFINITY, 1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(%f,%.1f), expected %f, got %f",
|
||||
INFINITY, 1.0, NAN, result);
|
||||
|
||||
result = SDL_fmod(-INFINITY, -1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(%f,%.1f), expected %f, got %f",
|
||||
-INFINITY, -1.0, NAN, result);
|
||||
|
||||
result = SDL_fmod(-INFINITY, 1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(%f,%.1f), expected %f, got %f",
|
||||
-INFINITY, 1.0, NAN, result);
|
||||
|
||||
|
@ -909,22 +909,22 @@ fmod_divByZeroCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_fmod(1.0, 0.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(1.0,0.0), expected nan, got %f",
|
||||
result);
|
||||
|
||||
result = SDL_fmod(-1.0, 0.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(-1.0,0.0), expected nan, got %f",
|
||||
result);
|
||||
|
||||
result = SDL_fmod(1.0, -0.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(1.0,-0.0), expected nan, got %f",
|
||||
result);
|
||||
|
||||
result = SDL_fmod(-1.0, -0.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(-1.0,-0.0), expected nan, got %f",
|
||||
result);
|
||||
|
||||
|
@ -941,22 +941,22 @@ fmod_nanCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_fmod(NAN, 1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(nan,1.0), expected nan, got %f",
|
||||
result);
|
||||
|
||||
result = SDL_fmod(NAN, -1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(nan,-1.0), expected nan, got %f",
|
||||
result);
|
||||
|
||||
result = SDL_fmod(1.0, NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(1.0,nan), expected nan, got %f",
|
||||
result);
|
||||
|
||||
result = SDL_fmod(-1.0, NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Fmod(-1.0,nan), expected nan, got %f",
|
||||
result);
|
||||
|
||||
|
@ -996,7 +996,7 @@ fmod_rangeTest(void *args)
|
|||
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
|
||||
double result;
|
||||
/* These are tested elsewhere */
|
||||
if (isnan(test_value) || isinf(test_value)) {
|
||||
if (ISNAN(test_value) || ISINF(test_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1065,7 +1065,7 @@ exp_overflowCase(void *args)
|
|||
}
|
||||
|
||||
result = SDL_exp(710.0);
|
||||
SDLTest_AssertCheck(isinf(result),
|
||||
SDLTest_AssertCheck(ISINF(result),
|
||||
"Exp(%f), expected %f, got %f",
|
||||
710.0, INFINITY, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -1169,12 +1169,12 @@ log_nanCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_log(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Log(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
|
||||
result = SDL_log(-1234.5678);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Log(%f), expected %f, got %f",
|
||||
-1234.5678, NAN, result);
|
||||
|
||||
|
@ -1259,12 +1259,12 @@ log10_nanCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_log10(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Log10(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
|
||||
result = SDL_log10(-1234.5678);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Log10(%f), expected %f, got %f",
|
||||
-1234.5678, NAN, result);
|
||||
|
||||
|
@ -1477,7 +1477,7 @@ static int
|
|||
pow_badOperationCase(void *args)
|
||||
{
|
||||
const double result = SDL_pow(-2.0, 4.2);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Pow(%f,%f), expected %f, got %f",
|
||||
-2.0, 4.2, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -1529,17 +1529,17 @@ pow_nanArgsCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_pow(7.8, NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Pow(%f,%f), expected %f, got %f",
|
||||
7.8, NAN, NAN, result);
|
||||
|
||||
result = SDL_pow(NAN, 10.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Pow(%f,%f), expected %f, got %f",
|
||||
NAN, 10.0, NAN, result);
|
||||
|
||||
result = SDL_pow(NAN, NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Pow(%f,%f), expected %f, got %f",
|
||||
NAN, NAN, NAN, result);
|
||||
|
||||
|
@ -1727,7 +1727,7 @@ pow_rangeTest(void *args)
|
|||
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
|
||||
double result;
|
||||
/* These are tested elsewhere */
|
||||
if (isnan(test_value) || isinf(test_value)) {
|
||||
if (ISNAN(test_value) || ISINF(test_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1775,7 +1775,7 @@ static int
|
|||
sqrt_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_sqrt(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Sqrt(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -1791,17 +1791,17 @@ sqrt_outOfDomainCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_sqrt(-1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Sqrt(%f), expected %f, got %f",
|
||||
-1.0, NAN, result);
|
||||
|
||||
result = SDL_sqrt(-12345.6789);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Sqrt(%f), expected %f, got %f",
|
||||
-12345.6789, NAN, result);
|
||||
|
||||
result = SDL_sqrt(-INFINITY);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Sqrt(%f), expected %f, got %f",
|
||||
-INFINITY, NAN, result);
|
||||
|
||||
|
@ -1910,7 +1910,7 @@ static int
|
|||
scalbn_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_scalbn(NAN, 2);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Scalbn(%f,%d), expected %f, got %f",
|
||||
NAN, 2, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -1965,12 +1965,12 @@ cos_infCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_cos(INFINITY);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Cos(%f), expected %f, got %f",
|
||||
INFINITY, NAN, result);
|
||||
|
||||
result = SDL_cos(-INFINITY);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Cos(%f), expected %f, got %f",
|
||||
-INFINITY, NAN, result);
|
||||
|
||||
|
@ -1985,7 +1985,7 @@ static int
|
|||
cos_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_cos(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Cos(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -2054,7 +2054,7 @@ cos_rangeTest(void *args)
|
|||
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
|
||||
double result;
|
||||
/* These are tested elsewhere */
|
||||
if (isnan(test_value) || isinf(test_value)) {
|
||||
if (ISNAN(test_value) || ISINF(test_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2082,12 +2082,12 @@ sin_infCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_sin(INFINITY);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Sin(%f), expected %f, got %f",
|
||||
INFINITY, NAN, result);
|
||||
|
||||
result = SDL_sin(-INFINITY);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Sin(%f), expected %f, got %f",
|
||||
-INFINITY, NAN, result);
|
||||
|
||||
|
@ -2102,7 +2102,7 @@ static int
|
|||
sin_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_sin(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Sin(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -2172,7 +2172,7 @@ sin_rangeTest(void *args)
|
|||
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
|
||||
double result;
|
||||
/* These are tested elsewhere */
|
||||
if (isnan(test_value) || isinf(test_value)) {
|
||||
if (ISNAN(test_value) || ISINF(test_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2200,12 +2200,12 @@ tan_infCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_tan(INFINITY);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Tan(%f), expected %f, got %f",
|
||||
INFINITY, NAN, result);
|
||||
|
||||
result = SDL_tan(-INFINITY);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Tan(%f), expected %f, got %f",
|
||||
-INFINITY, NAN, result);
|
||||
|
||||
|
@ -2220,7 +2220,7 @@ static int
|
|||
tan_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_tan(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Tan(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -2307,12 +2307,12 @@ acos_outOfDomainCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_acos(1.1);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Acos(%f), expected %f, got %f",
|
||||
1.1, NAN, result);
|
||||
|
||||
result = SDL_acos(-1.1);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Acos(%f), expected %f, got %f",
|
||||
-1.1, NAN, result);
|
||||
|
||||
|
@ -2327,7 +2327,7 @@ static int
|
|||
acos_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_acos(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Acos(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -2399,12 +2399,12 @@ asin_outOfDomainCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_asin(1.1);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Asin(%f), expected %f, got %f",
|
||||
1.1, NAN, result);
|
||||
|
||||
result = SDL_asin(-1.1);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Asin(%f), expected %f, got %f",
|
||||
-1.1, NAN, result);
|
||||
|
||||
|
@ -2419,7 +2419,7 @@ static int
|
|||
asin_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_asin(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Asin(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -2513,7 +2513,7 @@ static int
|
|||
atan_nanCase(void *args)
|
||||
{
|
||||
const double result = SDL_atan(NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Atan(%f), expected %f, got %f",
|
||||
NAN, NAN, result);
|
||||
return TEST_COMPLETED;
|
||||
|
@ -2723,17 +2723,17 @@ atan2_nanCases(void *args)
|
|||
double result;
|
||||
|
||||
result = SDL_atan2(NAN, NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
NAN, NAN, NAN, result);
|
||||
|
||||
result = SDL_atan2(NAN, 1.0);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
NAN, 1.0, NAN, result);
|
||||
|
||||
result = SDL_atan2(1.0, NAN);
|
||||
SDLTest_AssertCheck(isnan(result),
|
||||
SDLTest_AssertCheck(ISNAN(result),
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
1.0, NAN, NAN, result);
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#define ISFINITE(X) isfinite((float)(X))
|
||||
#define ISINF(X) isinf((float)(X))
|
||||
#define ISNAN(X) isnan((float)(X))
|
||||
|
||||
/* Test collections */
|
||||
extern SDLTest_TestSuiteReference audioTestSuite;
|
||||
extern SDLTest_TestSuiteReference clipboardTestSuite;
|
||||
|
|
|
@ -1492,7 +1492,7 @@ int main(int argc, char *argv[])
|
|||
positions[i].h = (float)sprite_h;
|
||||
velocities[i].x = 0.0f;
|
||||
velocities[i].y = 0.0f;
|
||||
while (!velocities[i].x || !velocities[i].y) {
|
||||
while (velocities[i].x == 0.f || velocities[i].y == 0.f) {
|
||||
velocities[i].x = (float)((rand() % (2 + 1)) - 1);
|
||||
velocities[i].y = (float)((rand() % (2 + 1)) - 1);
|
||||
}
|
||||
|
|
|
@ -498,7 +498,7 @@ Render(unsigned int width, unsigned int height, shader_data *data)
|
|||
multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
|
||||
|
||||
/* Pull the camera back from the cube */
|
||||
matrix_modelview[14] -= 2.5;
|
||||
matrix_modelview[14] -= 2.5f;
|
||||
|
||||
perspective_matrix(45.0f, (float)width / height, 0.01f, 100.0f, matrix_perspective);
|
||||
multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp);
|
||||
|
|
|
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
|
|||
positions[i].h = (float)sprite_h;
|
||||
velocities[i].x = 0.0f;
|
||||
velocities[i].y = 0.0f;
|
||||
while (!velocities[i].x && !velocities[i].y) {
|
||||
while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
|
||||
velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
}
|
||||
|
|
|
@ -568,7 +568,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||
positions[i].h = sprite_h;
|
||||
velocities[i].x = 0;
|
||||
velocities[i].y = 0;
|
||||
while (!velocities[i].x && !velocities[i].y) {
|
||||
while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
|
||||
velocities[i].x = (float)SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED);
|
||||
velocities[i].y = (float)SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ int main(int argc, char *argv[])
|
|||
positions[i].h = (float)sprite_h;
|
||||
velocities[i].x = 0.0f;
|
||||
velocities[i].y = 0.0f;
|
||||
while (!velocities[i].x && !velocities[i].y) {
|
||||
while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
|
||||
velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ static int InitSprites(void)
|
|||
positions[i].h = (float)sprite_h;
|
||||
velocities[i].x = 0.0f;
|
||||
velocities[i].y = 0.0f;
|
||||
while (!velocities[i].x && !velocities[i].y) {
|
||||
while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
|
||||
velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue