Removed SDL_stdinc.h dependency on HAVE_M_PI, added SDL_M_PIl (double) and SDL_M_PIf (float) instead
parent
8733927e35
commit
670f1df469
|
@ -6,4 +6,5 @@ This is a list of major changes in SDL's version history.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
General:
|
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
|
||||||
* SDL_GetWindowWMInfo() returns a standard int result code instead of SDL_bool, and takes SDL_SYSWM_CURRENT_VERSION as a new third parameter
|
* SDL_GetWindowWMInfo() returns a standard int result code instead of SDL_bool, and takes SDL_SYSWM_CURRENT_VERSION as a new third parameter
|
||||||
|
|
|
@ -4,6 +4,10 @@ This guide provides useful information for migrating applications from SDL 2.0 t
|
||||||
|
|
||||||
We have provided a handy Python script to automate some of this work for you [link to script], and details on the changes are organized by SDL 2.0 header below.
|
We have provided a handy Python script to automate some of this work for you [link to script], and details on the changes are organized by SDL 2.0 header below.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
## SDL_syswm.h
|
## SDL_syswm.h
|
||||||
|
|
||||||
This header no longer includes platform specific headers and type definitions, instead allowing you to include the ones appropriate for your use case. You should define one or more of the following to enable the relevant platform-specific support:
|
This header no longer includes platform specific headers and type definitions, instead allowing you to include the ones appropriate for your use case. You should define one or more of the following to enable the relevant platform-specific support:
|
||||||
|
|
|
@ -80,13 +80,6 @@
|
||||||
# include <ctype.h>
|
# include <ctype.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_MATH_H
|
#ifdef HAVE_MATH_H
|
||||||
# if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
|
|
||||||
/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
|
|
||||||
Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
|
|
||||||
for more information.
|
|
||||||
*/
|
|
||||||
# define _USE_MATH_DEFINES
|
|
||||||
# endif
|
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_FLOAT_H
|
#ifdef HAVE_FLOAT_H
|
||||||
|
@ -615,10 +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_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);
|
extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, const char *fmt, va_list ap);
|
||||||
|
|
||||||
#ifndef HAVE_M_PI
|
#ifndef SDL_M_PIl
|
||||||
#ifndef M_PI
|
#define SDL_M_PIl 3.141592653589793238462643383279502884L /**< pi (double) */
|
||||||
#define M_PI 3.14159265358979323846264338327950288 /**< pi */
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef SDL_M_PIf
|
||||||
|
#define SDL_M_PIf ((float)3.141592653589793238462643383279502884) /**< pi (float) */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -304,9 +304,9 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ)
|
||||||
-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-
|
-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-
|
||||||
-"http://depts.washington.edu/aimgroup/proj/dollar/"
|
-"http://depts.washington.edu/aimgroup/proj/dollar/"
|
||||||
*/
|
*/
|
||||||
double ta = -M_PI/4;
|
double ta = -SDL_M_PIl/4;
|
||||||
double tb = M_PI/4;
|
double tb = SDL_M_PIl/4;
|
||||||
double dt = M_PI/90;
|
double dt = SDL_M_PIl/90;
|
||||||
float x1 = (float)(PHI*ta + (1-PHI)*tb);
|
float x1 = (float)(PHI*ta + (1-PHI)*tb);
|
||||||
float f1 = dollarDifference(points,templ,x1);
|
float f1 = dollarDifference(points,templ,x1);
|
||||||
float x2 = (float)((1-PHI)*ta + PHI*tb);
|
float x2 = (float)((1-PHI)*ta + PHI*tb);
|
||||||
|
|
|
@ -37,11 +37,6 @@
|
||||||
#include <errno.h> /* errno, strerror */
|
#include <errno.h> /* errno, strerror */
|
||||||
#include <sys/stat.h> /* stat */
|
#include <sys/stat.h> /* stat */
|
||||||
|
|
||||||
/* Just in case. */
|
|
||||||
#ifndef M_PI
|
|
||||||
# define M_PI 3.14159265358979323846
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */
|
#define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */
|
||||||
|
|
||||||
|
@ -721,7 +716,7 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
|
||||||
--> add 45000 in total
|
--> add 45000 in total
|
||||||
--> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
|
--> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
|
||||||
*/
|
*/
|
||||||
tmp = (((Sint32) (f * 18000. / M_PI)) + 45000) % 36000;
|
tmp = (((Sint32) (f * 18000.0 / SDL_M_PIl)) + 45000) % 36000;
|
||||||
tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */
|
tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */
|
||||||
*dest = (Uint16) tmp;
|
*dest = (Uint16) tmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,7 +567,7 @@ HIDAPI_DriverPS4_ApplyCalibrationData(SDL_DriverPS4_Context *ctx, int index, Sin
|
||||||
|
|
||||||
/* Convert the raw data to the units expected by SDL */
|
/* Convert the raw data to the units expected by SDL */
|
||||||
if (index < 3) {
|
if (index < 3) {
|
||||||
result = (result / GYRO_RES_PER_DEGREE) * (float)M_PI / 180.0f;
|
result = (result / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f;
|
||||||
} else {
|
} else {
|
||||||
result = (result / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
result = (result / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,7 +612,7 @@ HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, int index, Sin
|
||||||
|
|
||||||
/* Convert the raw data to the units expected by SDL */
|
/* Convert the raw data to the units expected by SDL */
|
||||||
if (index < 3) {
|
if (index < 3) {
|
||||||
result = (result / GYRO_RES_PER_DEGREE) * (float)M_PI / 180.0f;
|
result = (result / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f;
|
||||||
} else {
|
} else {
|
||||||
result = (result / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
result = (result / ACCEL_RES_PER_G) * SDL_STANDARD_GRAVITY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1260,9 +1260,9 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||||
|
|
||||||
ctx->timestamp_us += ctx->update_rate_in_us;
|
ctx->timestamp_us += ctx->update_rate_in_us;
|
||||||
|
|
||||||
values[0] = (ctx->m_state.sGyroX / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f));
|
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 * ((float)M_PI / 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 * ((float)M_PI / 180.0f));
|
values[2] = (ctx->m_state.sGyroY / 32768.0f) * (2000.0f * (SDL_M_PIf / 180.0f));
|
||||||
SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, ctx->timestamp_us, values, 3);
|
SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, ctx->timestamp_us, values, 3);
|
||||||
|
|
||||||
values[0] = (ctx->m_state.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
|
values[0] = (ctx->m_state.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
|
||||||
|
|
|
@ -805,7 +805,7 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context* ctx)
|
||||||
|
|
||||||
if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t*)&readParams, sizeof(readParams), &reply)) {
|
if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t*)&readParams, sizeof(readParams), &reply)) {
|
||||||
const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE;
|
const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE;
|
||||||
const float gyroScale = (float)M_PI / 180.0f / SWITCH_GYRO_SCALE;
|
const float gyroScale = SDL_M_PIf / 180.0f / SWITCH_GYRO_SCALE;
|
||||||
|
|
||||||
ctx->m_IMUScaleData.fAccelScaleX = accelScale;
|
ctx->m_IMUScaleData.fAccelScaleX = accelScale;
|
||||||
ctx->m_IMUScaleData.fAccelScaleY = 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;
|
ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (float)(SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
|
||||||
|
|
||||||
/* Gyro scale */
|
/* Gyro scale */
|
||||||
ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * (float)M_PI / 180.0f;
|
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) * (float)M_PI / 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) * (float)M_PI / 180.0f;
|
ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * SDL_M_PIf / 180.0f;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1192,9 +1192,9 @@ static void HandleMotionPlusData(SDL_DriverWii_Context *ctx, SDL_Joystick *joyst
|
||||||
z *= 2000;
|
z *= 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
values[0] = -((float)z / GYRO_RES_PER_DEGREE) * (float)M_PI / 180.0f;
|
values[0] = -((float)z / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f;
|
||||||
values[1] = ((float)x / GYRO_RES_PER_DEGREE) * (float)M_PI / 180.0f;
|
values[1] = ((float)x / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f;
|
||||||
values[2] = ((float)y / GYRO_RES_PER_DEGREE) * (float)M_PI / 180.0f;
|
values[2] = ((float)y / GYRO_RES_PER_DEGREE) * SDL_M_PIf / 180.0f;
|
||||||
SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, 0, values, 3);
|
SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, 0, values, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3679,7 +3679,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
float s_minx, s_miny, s_maxx, s_maxy;
|
float s_minx, s_miny, s_maxx, s_maxy;
|
||||||
float c_minx, c_miny, c_maxx, c_maxy;
|
float c_minx, c_miny, c_maxx, c_maxy;
|
||||||
|
|
||||||
const float radian_angle = (float)((M_PI * angle) / 180.0);
|
const float radian_angle = (float)((SDL_M_PIl * angle) / 180.0);
|
||||||
const float s = SDL_sinf(radian_angle);
|
const float s = SDL_sinf(radian_angle);
|
||||||
const float c = SDL_cosf(radian_angle);
|
const float c = SDL_cosf(radian_angle);
|
||||||
|
|
||||||
|
|
|
@ -1821,13 +1821,13 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
|
||||||
projection = MatrixIdentity();
|
projection = MatrixIdentity();
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE270:
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
projection = MatrixRotationZ(SDL_static_cast(float, M_PI * 0.5f));
|
projection = MatrixRotationZ(SDL_M_PIf * 0.5f);
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE180:
|
case DXGI_MODE_ROTATION_ROTATE180:
|
||||||
projection = MatrixRotationZ(SDL_static_cast(float, M_PI));
|
projection = MatrixRotationZ(SDL_M_PIf);
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE90:
|
case DXGI_MODE_ROTATION_ROTATE90:
|
||||||
projection = MatrixRotationZ(SDL_static_cast(float, -M_PI * 0.5f));
|
projection = MatrixRotationZ(-SDL_M_PIf * 0.5f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SDL_SetError("An unknown DisplayOrientation is being used");
|
return SDL_SetError("An unknown DisplayOrientation is being used");
|
||||||
|
|
|
@ -2366,13 +2366,13 @@ D3D12_UpdateViewport(SDL_Renderer * renderer)
|
||||||
projection = MatrixIdentity();
|
projection = MatrixIdentity();
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE270:
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
projection = MatrixRotationZ(SDL_static_cast(float, M_PI * 0.5f));
|
projection = MatrixRotationZ(SDL_M_PIf * 0.5f);
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE180:
|
case DXGI_MODE_ROTATION_ROTATE180:
|
||||||
projection = MatrixRotationZ(SDL_static_cast(float, M_PI));
|
projection = MatrixRotationZ(SDL_M_PIf);
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE90:
|
case DXGI_MODE_ROTATION_ROTATE90:
|
||||||
projection = MatrixRotationZ(SDL_static_cast(float, -M_PI * 0.5f));
|
projection = MatrixRotationZ(-SDL_M_PIf * 0.5f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SDL_SetError("An unknown DisplayOrientation is being used");
|
return SDL_SetError("An unknown DisplayOrientation is being used");
|
||||||
|
|
|
@ -122,7 +122,7 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||||
double sinangle;
|
double sinangle;
|
||||||
double cosangle;
|
double cosangle;
|
||||||
|
|
||||||
radangle = angle * (M_PI / 180.0);
|
radangle = angle * (SDL_M_PIl / 180.0);
|
||||||
sinangle = SDL_sin(radangle);
|
sinangle = SDL_sin(radangle);
|
||||||
cosangle = SDL_cos(radangle);
|
cosangle = SDL_cos(radangle);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
hrZ = ISensorDataReport_GetSensorValue(pNewData, &SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Z_DEGREES_PER_SECOND, &valueZ);
|
||||||
if (SUCCEEDED(hrX) && SUCCEEDED(hrY) && SUCCEEDED(hrZ) &&
|
if (SUCCEEDED(hrX) && SUCCEEDED(hrY) && SUCCEEDED(hrZ) &&
|
||||||
valueX.vt == VT_R8 && valueY.vt == VT_R8 && valueZ.vt == VT_R8) {
|
valueX.vt == VT_R8 && valueY.vt == VT_R8 && valueZ.vt == VT_R8) {
|
||||||
const float DEGREES_TO_RADIANS = (float)(M_PI / 180.0f);
|
const float DEGREES_TO_RADIANS = (SDL_M_PIf / 180.0f);
|
||||||
float values[3];
|
float values[3];
|
||||||
|
|
||||||
values[0] = (float)valueX.dblVal * DEGREES_TO_RADIANS;
|
values[0] = (float)valueX.dblVal * DEGREES_TO_RADIANS;
|
||||||
|
|
|
@ -79,12 +79,12 @@ SDL_acos(double val)
|
||||||
#else
|
#else
|
||||||
double result;
|
double result;
|
||||||
if (val == -1.0) {
|
if (val == -1.0) {
|
||||||
result = M_PI;
|
result = SDL_M_PIl;
|
||||||
} else {
|
} else {
|
||||||
result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
|
result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
|
||||||
if (result < 0.0)
|
if (result < 0.0)
|
||||||
{
|
{
|
||||||
result += M_PI;
|
result += SDL_M_PIl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -109,9 +109,9 @@ SDL_asin(double val)
|
||||||
#else
|
#else
|
||||||
double result;
|
double result;
|
||||||
if (val == -1.0) {
|
if (val == -1.0) {
|
||||||
result = -(M_PI / 2.0);
|
result = -(SDL_M_PIl / 2.0);
|
||||||
} else {
|
} else {
|
||||||
result = (M_PI / 2.0) - SDL_acos(val);
|
result = (SDL_M_PIl / 2.0) - SDL_acos(val);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue