From 0b8309da0cd9d199bc3243b1a94bce62510b6ad6 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 25 Nov 2022 22:35:24 +0300 Subject: [PATCH] renamed SDL PI constants to SDL_PI_D and SDL_PI_F. --- WhatsNew.txt | 2 +- docs/README-migration.md | 2 +- include/SDL_stdinc.h | 8 +- src/events/SDL_gesture.c | 6 +- src/haptic/linux/SDL_syshaptic.c | 2 +- src/joystick/hidapi/SDL_hidapi_ps4.c | 2 +- src/joystick/hidapi/SDL_hidapi_ps5.c | 2 +- src/joystick/hidapi/SDL_hidapi_steam.c | 6 +- src/joystick/hidapi/SDL_hidapi_switch.c | 8 +- src/joystick/hidapi/SDL_hidapi_wii.c | 6 +- src/render/SDL_render.c | 2 +- src/render/direct3d11/SDL_render_d3d11.c | 6 +- src/render/direct3d12/SDL_render_d3d12.c | 6 +- src/render/software/SDL_rotate.c | 2 +- src/sensor/windows/SDL_windowssensor.c | 2 +- src/stdlib/SDL_stdlib.c | 8 +- test/testautomation_math.c | 224 +++++++++++------------ test/testgles2.c | 2 +- test/testvulkan.c | 4 +- 19 files changed, 150 insertions(+), 150 deletions(-) diff --git a/WhatsNew.txt b/WhatsNew.txt index 3d90d8f53..dabef2fbf 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -6,6 +6,6 @@ This is a list of major changes in SDL's version history. --------------------------------------------------------------------------- General: -* M_PI is no longer defined in SDL_stdinc.h, now the symbols SDL_M_PIl (double) and SDL_M_PIf (float) are available +* M_PI is no longer defined in SDL_stdinc.h, now the symbols SDL_PI_D (double) and SDL_PI_F (float) are available * SDL_GetWindowWMInfo() returns a standard int result code instead of SDL_bool, and takes SDL_SYSWM_CURRENT_VERSION as a new third parameter * SDL_RWFromFP has been removed from the API diff --git a/docs/README-migration.md b/docs/README-migration.md index 3e165d18c..6297dfbcb 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -119,7 +119,7 @@ SDL_RWFromFP(void *fp, SDL_bool autoclose) ## SDL_stdinc.h -M_PI is no longer defined in SDL_stdinc.h, you can use the new symbols SDL_M_PIl (double) and SDL_M_PIf (float) instead. +M_PI is no longer defined in SDL_stdinc.h, you can use the new symbols SDL_PI_D (double) and SDL_PI_F (float) instead. ## SDL_syswm.h diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 5f29bb1e8..0e190b022 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -608,11 +608,11 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size extern DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, const char *fmt, va_list ap); -#ifndef SDL_M_PIl -#define SDL_M_PIl 3.141592653589793238462643383279502884L /**< pi (double) */ +#ifndef SDL_PI_D +#define SDL_PI_D 3.141592653589793238462643383279502884L /**< pi (double) */ #endif -#ifndef SDL_M_PIf -#define SDL_M_PIf ((float)3.141592653589793238462643383279502884) /**< pi (float) */ +#ifndef SDL_PI_F +#define SDL_PI_F 3.141592653589793238462643383279502884F /**< pi (float) */ #endif /** diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index c35dd9a04..6d823fdf6 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -304,9 +304,9 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT- -"http://depts.washington.edu/aimgroup/proj/dollar/" */ - double ta = -SDL_M_PIl/4; - double tb = SDL_M_PIl/4; - double dt = SDL_M_PIl/90; + double ta = -SDL_PI_D/4; + double tb = SDL_PI_D/4; + double dt = SDL_PI_D/90; float x1 = (float)(PHI*ta + (1-PHI)*tb); float f1 = dollarDifference(points,templ,x1); float x2 = (float)((1-PHI)*ta + PHI*tb); diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index de8cb27fb..e1f5b2289 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -716,7 +716,7 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) --> add 45000 in total --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ - tmp = (((Sint32) (f * 18000.0 / SDL_M_PIl)) + 45000) % 36000; + tmp = (((Sint32) (f * 18000.0 / SDL_PI_D)) + 45000) % 36000; tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c index e04bf6de2..cdea6ce71 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -567,7 +567,7 @@ HIDAPI_DriverPS4_ApplyCalibrationData(SDL_DriverPS4_Context *ctx, int index, Sin /* Convert the raw data to the units expected by SDL */ if (index < 3) { - result = (result / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f; + result = (result / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f; } else { result = (result / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index cfd88010c..d491255ab 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -612,7 +612,7 @@ HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, int index, Sin /* Convert the raw data to the units expected by SDL */ if (index < 3) { - result = (result / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f; + result = (result / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f; } else { result = (result / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY; } diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index f2a761e6b..1163252b9 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -1260,9 +1260,9 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) ctx->timestamp_us += ctx->update_rate_in_us; - values[0] = (ctx->m_state.sGyroX / 32768.0f) * (2000.0f * (SDL_M_PIf / 180.0f)); - values[1] = (ctx->m_state.sGyroZ / 32768.0f) * (2000.0f * (SDL_M_PIf / 180.0f)); - values[2] = (ctx->m_state.sGyroY / 32768.0f) * (2000.0f * (SDL_M_PIf / 180.0f)); + values[0] = (ctx->m_state.sGyroX / 32768.0f) * (2000.0f * (SDL_PI_F / 180.0f)); + values[1] = (ctx->m_state.sGyroZ / 32768.0f) * (2000.0f * (SDL_PI_F / 180.0f)); + values[2] = (ctx->m_state.sGyroY / 32768.0f) * (2000.0f * (SDL_PI_F / 180.0f)); SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, ctx->timestamp_us, values, 3); values[0] = (ctx->m_state.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY; diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 514c954a6..25b06acdb 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -805,7 +805,7 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context* ctx) if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t*)&readParams, sizeof(readParams), &reply)) { const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE; - const float gyroScale = SDL_M_PIf / 180.0f / SWITCH_GYRO_SCALE; + const float gyroScale = SDL_PI_F / 180.0f / SWITCH_GYRO_SCALE; ctx->m_IMUScaleData.fAccelScaleX = accelScale; ctx->m_IMUScaleData.fAccelScaleY = accelScale; @@ -850,9 +850,9 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context* ctx) ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (float)(SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY; /* Gyro scale */ - ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * SDL_M_PIf / 180.0f; - ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * SDL_M_PIf / 180.0f; - ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * SDL_M_PIf / 180.0f; + ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * SDL_PI_F / 180.0f; + ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * SDL_PI_F / 180.0f; + ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * SDL_PI_F / 180.0f; return SDL_TRUE; } diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index e76893433..d056d9f30 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -1192,9 +1192,9 @@ static void HandleMotionPlusData(SDL_DriverWii_Context *ctx, SDL_Joystick *joyst z *= 2000; } - values[0] = -((float)z / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f; - values[1] = ((float)x / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f; - values[2] = ((float)y / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f; + values[0] = -((float)z / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f; + values[1] = ((float)x / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f; + values[2] = ((float)y / GYRO_RES_PER_DEGREE) * SDL_PI_F / 180.0f; SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, 0, values, 3); } } diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index ea6517a6b..a2d6139df 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -3679,7 +3679,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, float s_minx, s_miny, s_maxx, s_maxy; float c_minx, c_miny, c_maxx, c_maxy; - const float radian_angle = (float)((SDL_M_PIl * angle) / 180.0); + const float radian_angle = (float)((SDL_PI_D * angle) / 180.0); const float s = SDL_sinf(radian_angle); const float c = SDL_cosf(radian_angle); diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 371226f2c..367eebc1c 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -1821,13 +1821,13 @@ D3D11_UpdateViewport(SDL_Renderer * renderer) projection = MatrixIdentity(); break; case DXGI_MODE_ROTATION_ROTATE270: - projection = MatrixRotationZ(SDL_M_PIf * 0.5f); + projection = MatrixRotationZ(SDL_PI_F * 0.5f); break; case DXGI_MODE_ROTATION_ROTATE180: - projection = MatrixRotationZ(SDL_M_PIf); + projection = MatrixRotationZ(SDL_PI_F); break; case DXGI_MODE_ROTATION_ROTATE90: - projection = MatrixRotationZ(-SDL_M_PIf * 0.5f); + projection = MatrixRotationZ(-SDL_PI_F * 0.5f); break; default: return SDL_SetError("An unknown DisplayOrientation is being used"); diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 032a45894..673b01734 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -2366,13 +2366,13 @@ D3D12_UpdateViewport(SDL_Renderer * renderer) projection = MatrixIdentity(); break; case DXGI_MODE_ROTATION_ROTATE270: - projection = MatrixRotationZ(SDL_M_PIf * 0.5f); + projection = MatrixRotationZ(SDL_PI_F * 0.5f); break; case DXGI_MODE_ROTATION_ROTATE180: - projection = MatrixRotationZ(SDL_M_PIf); + projection = MatrixRotationZ(SDL_PI_F); break; case DXGI_MODE_ROTATION_ROTATE90: - projection = MatrixRotationZ(-SDL_M_PIf * 0.5f); + projection = MatrixRotationZ(-SDL_PI_F * 0.5f); break; default: return SDL_SetError("An unknown DisplayOrientation is being used"); diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 2ea5c0138..140d398d7 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -122,7 +122,7 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP double sinangle; double cosangle; - radangle = angle * (SDL_M_PIl / 180.0); + radangle = angle * (SDL_PI_D / 180.0); sinangle = SDL_sin(radangle); cosangle = SDL_cos(radangle); diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c index e4b9f1f11..067226d64 100644 --- a/src/sensor/windows/SDL_windowssensor.c +++ b/src/sensor/windows/SDL_windowssensor.c @@ -180,7 +180,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents * hrZ = ISensorDataReport_GetSensorValue(pNewData, &SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Z_DEGREES_PER_SECOND, &valueZ); if (SUCCEEDED(hrX) && SUCCEEDED(hrY) && SUCCEEDED(hrZ) && valueX.vt == VT_R8 && valueY.vt == VT_R8 && valueZ.vt == VT_R8) { - const float DEGREES_TO_RADIANS = (SDL_M_PIf / 180.0f); + const float DEGREES_TO_RADIANS = (SDL_PI_F / 180.0f); float values[3]; values[0] = (float)valueX.dblVal * DEGREES_TO_RADIANS; diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index 8b87bad7d..1fd54231f 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -79,12 +79,12 @@ SDL_acos(double val) #else double result; if (val == -1.0) { - result = SDL_M_PIl; + result = SDL_PI_D; } else { result = SDL_atan(SDL_sqrt(1.0 - val * val) / val); if (result < 0.0) { - result += SDL_M_PIl; + result += SDL_PI_D; } } return result; @@ -109,9 +109,9 @@ SDL_asin(double val) #else double result; if (val == -1.0) { - result = -(SDL_M_PIl / 2.0); + result = -(SDL_PI_D / 2.0); } else { - result = (SDL_M_PIl / 2.0) - SDL_acos(val); + result = (SDL_PI_D / 2.0) - SDL_acos(val); } return result; #endif diff --git a/test/testautomation_math.c b/test/testautomation_math.c index e38a29382..78233d167 100644 --- a/test/testautomation_math.c +++ b/test/testautomation_math.c @@ -1963,10 +1963,10 @@ static int cos_regularCases(void *args) { const d_to_d regular_cases[] = { - { -SDL_M_PIl, -1.0 }, + { -SDL_PI_D, -1.0 }, { -0.0, 1.0 }, { 0.0, 1.0 }, - { SDL_M_PIl, -1.0 } + { SDL_PI_D, -1.0 } }; return helper_dtod("Cos", SDL_cos, regular_cases, SDL_arraysize(regular_cases)); } @@ -1979,24 +1979,24 @@ static int cos_precisionTest(void *args) { const d_to_d precision_cases[] = { - { SDL_M_PIl * 1.0 / 10.0, 0.9510565162 }, - { SDL_M_PIl * 2.0 / 10.0, 0.8090169943 }, - { SDL_M_PIl * 3.0 / 10.0, 0.5877852522 }, - { SDL_M_PIl * 4.0 / 10.0, 0.3090169943 }, - { SDL_M_PIl * 5.0 / 10.0, 0.0 }, - { SDL_M_PIl * 6.0 / 10.0, -0.3090169943 }, - { SDL_M_PIl * 7.0 / 10.0, -0.5877852522 }, - { SDL_M_PIl * 8.0 / 10.0, -0.8090169943 }, - { SDL_M_PIl * 9.0 / 10.0, -0.9510565162 }, - { SDL_M_PIl * -1.0 / 10.0, 0.9510565162 }, - { SDL_M_PIl * -2.0 / 10.0, 0.8090169943 }, - { SDL_M_PIl * -3.0 / 10.0, 0.5877852522 }, - { SDL_M_PIl * -4.0 / 10.0, 0.3090169943 }, - { SDL_M_PIl * -5.0 / 10.0, 0.0 }, - { SDL_M_PIl * -6.0 / 10.0, -0.3090169943 }, - { SDL_M_PIl * -7.0 / 10.0, -0.5877852522 }, - { SDL_M_PIl * -8.0 / 10.0, -0.8090169943 }, - { SDL_M_PIl * -9.0 / 10.0, -0.9510565162 } + { SDL_PI_D * 1.0 / 10.0, 0.9510565162 }, + { SDL_PI_D * 2.0 / 10.0, 0.8090169943 }, + { SDL_PI_D * 3.0 / 10.0, 0.5877852522 }, + { SDL_PI_D * 4.0 / 10.0, 0.3090169943 }, + { SDL_PI_D * 5.0 / 10.0, 0.0 }, + { SDL_PI_D * 6.0 / 10.0, -0.3090169943 }, + { SDL_PI_D * 7.0 / 10.0, -0.5877852522 }, + { SDL_PI_D * 8.0 / 10.0, -0.8090169943 }, + { SDL_PI_D * 9.0 / 10.0, -0.9510565162 }, + { SDL_PI_D * -1.0 / 10.0, 0.9510565162 }, + { SDL_PI_D * -2.0 / 10.0, 0.8090169943 }, + { SDL_PI_D * -3.0 / 10.0, 0.5877852522 }, + { SDL_PI_D * -4.0 / 10.0, 0.3090169943 }, + { SDL_PI_D * -5.0 / 10.0, 0.0 }, + { SDL_PI_D * -6.0 / 10.0, -0.3090169943 }, + { SDL_PI_D * -7.0 / 10.0, -0.5877852522 }, + { SDL_PI_D * -8.0 / 10.0, -0.8090169943 }, + { SDL_PI_D * -9.0 / 10.0, -0.9510565162 } }; return helper_dtod_inexact("Cos", SDL_cos, precision_cases, SDL_arraysize(precision_cases)); } @@ -2080,10 +2080,10 @@ static int sin_regularCases(void *args) { const d_to_d regular_cases[] = { - { -SDL_M_PIl / 2, -1.0 }, + { -SDL_PI_D / 2, -1.0 }, { -0.0, -0.0 }, { 0.0, 0.0 }, - { SDL_M_PIl / 2, 1.0 } + { SDL_PI_D / 2, 1.0 } }; return helper_dtod("Sin", SDL_sin, regular_cases, SDL_arraysize(regular_cases)); } @@ -2097,24 +2097,24 @@ static int sin_precisionTest(void *args) { const d_to_d precision_cases[] = { - { SDL_M_PIl * 1.0 / 10.0, 0.3090169943 }, - { SDL_M_PIl * 2.0 / 10.0, 0.5877852522 }, - { SDL_M_PIl * 3.0 / 10.0, 0.8090169943 }, - { SDL_M_PIl * 4.0 / 10.0, 0.9510565162 }, - { SDL_M_PIl * 6.0 / 10.0, 0.9510565162 }, - { SDL_M_PIl * 7.0 / 10.0, 0.8090169943 }, - { SDL_M_PIl * 8.0 / 10.0, 0.5877852522 }, - { SDL_M_PIl * 9.0 / 10.0, 0.3090169943 }, - { SDL_M_PIl, 0.0 }, - { SDL_M_PIl * -1.0 / 10.0, -0.3090169943 }, - { SDL_M_PIl * -2.0 / 10.0, -0.5877852522 }, - { SDL_M_PIl * -3.0 / 10.0, -0.8090169943 }, - { SDL_M_PIl * -4.0 / 10.0, -0.9510565162 }, - { SDL_M_PIl * -6.0 / 10.0, -0.9510565162 }, - { SDL_M_PIl * -7.0 / 10.0, -0.8090169943 }, - { SDL_M_PIl * -8.0 / 10.0, -0.5877852522 }, - { SDL_M_PIl * -9.0 / 10.0, -0.3090169943 }, - { -SDL_M_PIl, 0.0 }, + { SDL_PI_D * 1.0 / 10.0, 0.3090169943 }, + { SDL_PI_D * 2.0 / 10.0, 0.5877852522 }, + { SDL_PI_D * 3.0 / 10.0, 0.8090169943 }, + { SDL_PI_D * 4.0 / 10.0, 0.9510565162 }, + { SDL_PI_D * 6.0 / 10.0, 0.9510565162 }, + { SDL_PI_D * 7.0 / 10.0, 0.8090169943 }, + { SDL_PI_D * 8.0 / 10.0, 0.5877852522 }, + { SDL_PI_D * 9.0 / 10.0, 0.3090169943 }, + { SDL_PI_D, 0.0 }, + { SDL_PI_D * -1.0 / 10.0, -0.3090169943 }, + { SDL_PI_D * -2.0 / 10.0, -0.5877852522 }, + { SDL_PI_D * -3.0 / 10.0, -0.8090169943 }, + { SDL_PI_D * -4.0 / 10.0, -0.9510565162 }, + { SDL_PI_D * -6.0 / 10.0, -0.9510565162 }, + { SDL_PI_D * -7.0 / 10.0, -0.8090169943 }, + { SDL_PI_D * -8.0 / 10.0, -0.5877852522 }, + { SDL_PI_D * -9.0 / 10.0, -0.3090169943 }, + { -SDL_PI_D, 0.0 }, }; return helper_dtod_inexact("Sin", SDL_sin, precision_cases, SDL_arraysize(precision_cases)); } @@ -2213,26 +2213,26 @@ static int tan_precisionTest(void *args) { const d_to_d precision_cases[] = { - { SDL_M_PIl * 1.0 / 11.0, 0.2936264929 }, - { SDL_M_PIl * 2.0 / 11.0, 0.6426609771 }, - { SDL_M_PIl * 3.0 / 11.0, 1.1540615205 }, - { SDL_M_PIl * 4.0 / 11.0, 2.1896945629 }, - { SDL_M_PIl * 5.0 / 11.0, 6.9551527717 }, - { SDL_M_PIl * 6.0 / 11.0, -6.9551527717 }, - { SDL_M_PIl * 7.0 / 11.0, -2.1896945629 }, - { SDL_M_PIl * 8.0 / 11.0, -1.1540615205 }, - { SDL_M_PIl * 9.0 / 11.0, -0.6426609771 }, - { SDL_M_PIl * 10.0 / 11.0, -0.2936264929 }, - { SDL_M_PIl * -1.0 / 11.0, -0.2936264929 }, - { SDL_M_PIl * -2.0 / 11.0, -0.6426609771 }, - { SDL_M_PIl * -3.0 / 11.0, -1.1540615205 }, - { SDL_M_PIl * -4.0 / 11.0, -2.1896945629 }, - { SDL_M_PIl * -5.0 / 11.0, -6.9551527717 }, - { SDL_M_PIl * -6.0 / 11.0, 6.9551527717 }, - { SDL_M_PIl * -7.0 / 11.0, 2.1896945629 }, - { SDL_M_PIl * -8.0 / 11.0, 1.1540615205 }, - { SDL_M_PIl * -9.0 / 11.0, 0.6426609771 }, - { SDL_M_PIl * -10.0 / 11.0, 0.2936264929 } + { SDL_PI_D * 1.0 / 11.0, 0.2936264929 }, + { SDL_PI_D * 2.0 / 11.0, 0.6426609771 }, + { SDL_PI_D * 3.0 / 11.0, 1.1540615205 }, + { SDL_PI_D * 4.0 / 11.0, 2.1896945629 }, + { SDL_PI_D * 5.0 / 11.0, 6.9551527717 }, + { SDL_PI_D * 6.0 / 11.0, -6.9551527717 }, + { SDL_PI_D * 7.0 / 11.0, -2.1896945629 }, + { SDL_PI_D * 8.0 / 11.0, -1.1540615205 }, + { SDL_PI_D * 9.0 / 11.0, -0.6426609771 }, + { SDL_PI_D * 10.0 / 11.0, -0.2936264929 }, + { SDL_PI_D * -1.0 / 11.0, -0.2936264929 }, + { SDL_PI_D * -2.0 / 11.0, -0.6426609771 }, + { SDL_PI_D * -3.0 / 11.0, -1.1540615205 }, + { SDL_PI_D * -4.0 / 11.0, -2.1896945629 }, + { SDL_PI_D * -5.0 / 11.0, -6.9551527717 }, + { SDL_PI_D * -6.0 / 11.0, 6.9551527717 }, + { SDL_PI_D * -7.0 / 11.0, 2.1896945629 }, + { SDL_PI_D * -8.0 / 11.0, 1.1540615205 }, + { SDL_PI_D * -9.0 / 11.0, 0.6426609771 }, + { SDL_PI_D * -10.0 / 11.0, 0.2936264929 } }; return helper_dtod_inexact("Tan", SDL_tan, precision_cases, SDL_arraysize(precision_cases)); } @@ -2254,9 +2254,9 @@ acos_limitCases(void *args) 1.0, 0.0, result); result = SDL_acos(-1.0); - SDLTest_AssertCheck(SDL_M_PIl == result, + SDLTest_AssertCheck(SDL_PI_D == result, "Acos(%f), expected %f, got %f", - -1.0, SDL_M_PIl, result); + -1.0, SDL_PI_D, result); return TEST_COMPLETED; } @@ -2341,14 +2341,14 @@ asin_limitCases(void *args) double result; result = SDL_asin(1.0); - SDLTest_AssertCheck(SDL_M_PIl / 2.0 == result, + SDLTest_AssertCheck(SDL_PI_D / 2.0 == result, "Asin(%f), expected %f, got %f", - 1.0, SDL_M_PIl / 2.0, result); + 1.0, SDL_PI_D / 2.0, result); result = SDL_asin(-1.0); - SDLTest_AssertCheck(-SDL_M_PIl / 2.0 == result, + SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result, "Asin(%f), expected %f, got %f", - -1.0, -SDL_M_PIl / 2.0, result); + -1.0, -SDL_PI_D / 2.0, result); return TEST_COMPLETED; } @@ -2433,16 +2433,16 @@ atan_limitCases(void *args) double result; result = SDL_atan(INFINITY); - SDLTest_AssertCheck((SDL_M_PIl / 2.0) - EPSILON <= result && - result <= (SDL_M_PIl / 2.0) + EPSILON, + SDLTest_AssertCheck((SDL_PI_D / 2.0) - EPSILON <= result && + result <= (SDL_PI_D / 2.0) + EPSILON, "Atan(%f), expected %f, got %f", - INFINITY, SDL_M_PIl / 2.0, result); + INFINITY, SDL_PI_D / 2.0, result); result = SDL_atan(-INFINITY); - SDLTest_AssertCheck((-SDL_M_PIl / 2.0) - EPSILON <= result && - result <= (-SDL_M_PIl / 2.0) + EPSILON, + SDLTest_AssertCheck((-SDL_PI_D / 2.0) - EPSILON <= result && + result <= (-SDL_PI_D / 2.0) + EPSILON, "Atan(%f), expected %f, got %f", - -INFINITY, -SDL_M_PIl / 2.0, result); + -INFINITY, -SDL_PI_D / 2.0, result); return TEST_COMPLETED; } @@ -2530,8 +2530,8 @@ atan2_bothZeroCases(void *args) const dd_to_d cases[] = { { 0.0, 0.0, 0.0 }, { -0.0, 0.0, -0.0 }, - { 0.0, -0.0, SDL_M_PIl }, - { -0.0, -0.0, -SDL_M_PIl }, + { 0.0, -0.0, SDL_PI_D }, + { -0.0, -0.0, -SDL_PI_D }, }; return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); } @@ -2548,9 +2548,9 @@ atan2_yZeroCases(void *args) { const dd_to_d cases[] = { { 0.0, 1.0, 0.0 }, - { 0.0, -1.0, SDL_M_PIl }, + { 0.0, -1.0, SDL_PI_D }, { -0.0, 1.0, -0.0 }, - { -0.0, -1.0, -SDL_M_PIl } + { -0.0, -1.0, -SDL_PI_D } }; return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); } @@ -2563,10 +2563,10 @@ static int atan2_xZeroCases(void *args) { const dd_to_d cases[] = { - { 1.0, 0.0, SDL_M_PIl / 2.0 }, - { -1.0, 0.0, -SDL_M_PIl / 2.0 }, - { 1.0, -0.0, SDL_M_PIl / 2.0 }, - { -1.0, -0.0, -SDL_M_PIl / 2.0 } + { 1.0, 0.0, SDL_PI_D / 2.0 }, + { -1.0, 0.0, -SDL_PI_D / 2.0 }, + { 1.0, -0.0, SDL_PI_D / 2.0 }, + { -1.0, -0.0, -SDL_PI_D / 2.0 } }; return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); } @@ -2587,24 +2587,24 @@ atan2_bothInfCases(void *args) double result; result = SDL_atan2(INFINITY, INFINITY); - SDLTest_AssertCheck(SDL_M_PIl / 4.0 == result, + SDLTest_AssertCheck(SDL_PI_D / 4.0 == result, "Atan2(%f,%f), expected %f, got %f", - INFINITY, INFINITY, SDL_M_PIl / 4.0, result); + INFINITY, INFINITY, SDL_PI_D / 4.0, result); result = SDL_atan2(INFINITY, -INFINITY); - SDLTest_AssertCheck(3.0 * SDL_M_PIl / 4.0 == result, + SDLTest_AssertCheck(3.0 * SDL_PI_D / 4.0 == result, "Atan2(%f,%f), expected %f, got %f", - INFINITY, -INFINITY, 3.0 * SDL_M_PIl / 4.0, result); + INFINITY, -INFINITY, 3.0 * SDL_PI_D / 4.0, result); result = SDL_atan2(-INFINITY, INFINITY); - SDLTest_AssertCheck(-SDL_M_PIl / 4.0 == result, + SDLTest_AssertCheck(-SDL_PI_D / 4.0 == result, "Atan2(%f,%f), expected %f, got %f", - -INFINITY, INFINITY, -SDL_M_PIl / 4.0, result); + -INFINITY, INFINITY, -SDL_PI_D / 4.0, result); result = SDL_atan2(-INFINITY, -INFINITY); - SDLTest_AssertCheck(-3.0 * SDL_M_PIl / 4.0 == result, + SDLTest_AssertCheck(-3.0 * SDL_PI_D / 4.0 == result, "Atan2(%f,%f), expected %f, got %f", - -INFINITY, -INFINITY, -3.0 * SDL_M_PIl / 4.0, result); + -INFINITY, -INFINITY, -3.0 * SDL_PI_D / 4.0, result); return TEST_COMPLETED; } @@ -2619,24 +2619,24 @@ atan2_yInfCases(void *args) double result; result = SDL_atan2(INFINITY, 1.0); - SDLTest_AssertCheck(SDL_M_PIl / 2.0 == result, + SDLTest_AssertCheck(SDL_PI_D / 2.0 == result, "Atan2(%f,%f), expected %f, got %f", - INFINITY, 1.0, SDL_M_PIl / 2.0, result); + INFINITY, 1.0, SDL_PI_D / 2.0, result); result = SDL_atan2(INFINITY, -1.0); - SDLTest_AssertCheck(SDL_M_PIl / 2.0 == result, + SDLTest_AssertCheck(SDL_PI_D / 2.0 == result, "Atan2(%f,%f), expected %f, got %f", - INFINITY, -1.0, SDL_M_PIl / 2.0, result); + INFINITY, -1.0, SDL_PI_D / 2.0, result); result = SDL_atan2(-INFINITY, 1.0); - SDLTest_AssertCheck(-SDL_M_PIl / 2.0 == result, + SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result, "Atan2(%f,%f), expected %f, got %f", - -INFINITY, 1.0, -SDL_M_PIl / 2.0, result); + -INFINITY, 1.0, -SDL_PI_D / 2.0, result); result = SDL_atan2(-INFINITY, -1.0); - SDLTest_AssertCheck(-SDL_M_PIl / 2.0 == result, + SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result, "Atan2(%f,%f), expected %f, got %f", - -INFINITY, -1.0, -SDL_M_PIl / 2.0, result); + -INFINITY, -1.0, -SDL_PI_D / 2.0, result); return TEST_COMPLETED; } @@ -2663,14 +2663,14 @@ atan2_xInfCases(void *args) -1.0, INFINITY, -0.0, result); result = SDL_atan2(1.0, -INFINITY); - SDLTest_AssertCheck(SDL_M_PIl == result, + SDLTest_AssertCheck(SDL_PI_D == result, "Atan2(%f,%f), expected %f, got %f", - 1.0, -INFINITY, SDL_M_PIl, result); + 1.0, -INFINITY, SDL_PI_D, result); result = SDL_atan2(-1.0, -INFINITY); - SDLTest_AssertCheck(-SDL_M_PIl == result, + SDLTest_AssertCheck(-SDL_PI_D == result, "Atan2(%f,%f), expected %f, got %f", - -1.0, -INFINITY, -SDL_M_PIl, result); + -1.0, -INFINITY, -SDL_PI_D, result); return TEST_COMPLETED; } @@ -2712,9 +2712,9 @@ static int atan2_topRightQuadrantTest(void *args) { const dd_to_d top_right_cases[] = { - { 1.0, 1.0, SDL_M_PIl / 4.0 }, - { SQRT3, 3.0, SDL_M_PIl / 6.0 }, - { SQRT3, 1.0, SDL_M_PIl / 3.0 } + { 1.0, 1.0, SDL_PI_D / 4.0 }, + { SQRT3, 3.0, SDL_PI_D / 6.0 }, + { SQRT3, 1.0, SDL_PI_D / 3.0 } }; return helper_ddtod_inexact("SDL_atan2", SDL_atan2, top_right_cases, SDL_arraysize(top_right_cases)); } @@ -2727,9 +2727,9 @@ static int atan2_topLeftQuadrantTest(void *args) { const dd_to_d top_left_cases[] = { - { 1.0, -1.0, 3.0 * SDL_M_PIl / 4.0 }, - { SQRT3, -3.0, 5.0 * SDL_M_PIl / 6.0 }, - { SQRT3, -1.0, 2.0 * SDL_M_PIl / 3.0 } + { 1.0, -1.0, 3.0 * SDL_PI_D / 4.0 }, + { SQRT3, -3.0, 5.0 * SDL_PI_D / 6.0 }, + { SQRT3, -1.0, 2.0 * SDL_PI_D / 3.0 } }; return helper_ddtod_inexact("SDL_atan2", SDL_atan2, top_left_cases, SDL_arraysize(top_left_cases)); } @@ -2742,9 +2742,9 @@ static int atan2_bottomRightQuadrantTest(void *args) { const dd_to_d bottom_right_cases[] = { - { -1.0, 1.0, -SDL_M_PIl / 4 }, - { -SQRT3, 3.0, -SDL_M_PIl / 6.0 }, - { -SQRT3, 1.0, -SDL_M_PIl / 3.0 } + { -1.0, 1.0, -SDL_PI_D / 4 }, + { -SQRT3, 3.0, -SDL_PI_D / 6.0 }, + { -SQRT3, 1.0, -SDL_PI_D / 3.0 } }; return helper_ddtod_inexact("SDL_atan2", SDL_atan2, bottom_right_cases, SDL_arraysize(bottom_right_cases)); } @@ -2757,9 +2757,9 @@ static int atan2_bottomLeftQuadrantTest(void *args) { const dd_to_d bottom_left_cases[] = { - { -1.0, -1.0, -3.0 * SDL_M_PIl / 4.0 }, - { -SQRT3, -3.0, -5.0 * SDL_M_PIl / 6.0 }, - { -SQRT3, -1.0, -4.0 * SDL_M_PIl / 6.0 } + { -1.0, -1.0, -3.0 * SDL_PI_D / 4.0 }, + { -SQRT3, -3.0, -5.0 * SDL_PI_D / 6.0 }, + { -SQRT3, -1.0, -4.0 * SDL_PI_D / 6.0 } }; return helper_ddtod_inexact("SDL_atan2", SDL_atan2, bottom_left_cases, SDL_arraysize(bottom_left_cases)); } diff --git a/test/testgles2.c b/test/testgles2.c index cae9b9b02..dfd8694b3 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -127,7 +127,7 @@ rotate_matrix(float angle, float x, float y, float z, float *r) float radians, c, s, c1, u[3], length; int i, j; - radians = (angle * SDL_M_PIf) / 180.0f; + radians = (angle * SDL_PI_F) / 180.0f; c = SDL_cosf(radians); s = SDL_sinf(radians); diff --git a/test/testvulkan.c b/test/testvulkan.c index a5d07a02e..f919c55f0 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -1032,8 +1032,8 @@ static SDL_bool render(void) } currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency(); clearColor.float32[0] = (float)(0.5 + 0.5 * SDL_sin(currentTime)); - clearColor.float32[1] = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_M_PIl * 2 / 3)); - clearColor.float32[2] = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_M_PIl * 4 / 3)); + clearColor.float32[1] = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 2 / 3)); + clearColor.float32[2] = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 4 / 3)); clearColor.float32[3] = 1; rerecordCommandBuffer(frameIndex, &clearColor); submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;