Sam Lantinga
7f23d71b6a
Added SDL_modf() and SDL_modff()
...
This function is useful for accumulating relative mouse motion if you want to only handle whole pixel movement.
e.g.
static float dx_frac, dy_frac;
float dx, dy;
/* Accumulate new motion with previous sub-pixel motion */
dx = event.motion.xrel + dx_frac;
dy = event.motion.yrel + dy_frac;
/* Split the integral and fractional motion, dx and dy will contain whole pixel deltas */
dx_frac = SDL_modff(dx, &dx);
dy_frac = SDL_modff(dy, &dy);
if (dx != 0.0f || dy != 0.0f) {
...
}
2022-12-29 23:12:19 -08:00
Sam Lantinga
63724c113b
Removed the vi format comments from the source
...
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim ) to automatically set tab spacing for the SDL coding style.
Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Pierre Wendling
3c501b963d
Clang-Tidy fixes ( #6725 )
2022-12-01 13:07:03 -08:00
Sam Lantinga
5750bcb174
Update for SDL3 coding style ( #6717 )
...
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.
In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.
The script I ran for the src directory is added as build-scripts/clang-format-src.sh
This fixes:
#6592
#6593
#6594
2022-11-30 12:51:59 -08:00
Sam Lantinga
0a48abc860
Switch header convention from `#include "SDL.h"` to `#include <SDL3/SDLh>`
...
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```
I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
else
find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
fi
done
```
Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08:00
Sam Lantinga
63f307fe1f
Remove SDL_config.h from the public headers
...
The SDL headers are no longer dependent on the build configuration.
Fixes https://github.com/libsdl-org/SDL/issues/6643 and https://github.com/libsdl-org/SDL/issues/6641
2022-11-26 04:48:36 -08:00
Ozkan Sezer
0b8309da0c
renamed SDL PI constants to SDL_PI_D and SDL_PI_F.
2022-11-25 22:35:24 +03:00
Sam Lantinga
199423612c
Updated test programs with SDL_M_PI*
2022-11-25 10:57:12 -08:00
Pierre Wendling
6784d84c9d
N3DS: Fix `-Wformat` warnings in tests.
...
All warnings were about invalid specifiers. Since U/Sint32 is a long,
using `%d` emits a -Wformat warning.
2022-10-10 08:50:59 -07:00
Pierre Wendling
73d8d02629
Test: Fix Exp base case for Win32.
...
Add epsilon to the check.
2022-08-09 21:39:46 -07:00
Pierre Wendling
6bd3e0b189
Test: Check sqrt and atan against the epsilon.
...
On i686-linux, the `sqrt_regularCases` and `atan_limitCases` tests would
fail as the result was not precise enough.
2022-06-15 23:32:40 +03:00
Pierre Wendling
cee47a9ebe
Test: Use inexact helper for log10 regular cases.
...
On ARMv6, the result is not precise enough for this function.
2022-06-15 12:05:30 -07:00
Pierre Wendling
a52b8580f0
Test: Tidy up test descriptions and documentation.
...
Test function documentation now lists the input(s) and expected output(s).
Descriptions in TestCaseReference were updated.
2022-06-15 12:05:30 -07:00
Pierre Wendling
4d7f12f6bd
Test: Add Atan2 tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
8ebe640a36
Test: Change inexact tests to use an epsilon.
...
Instead of using `trunc` to check the first ten digits, inexact test now
relies on an epsilon defining an acceptable range for the expected
result to be in.
2022-06-15 12:05:30 -07:00
Pierre Wendling
62fd6aad39
Test: Add Atan tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
6a6e93bc29
Test: Add +/-0.0 tests to Acos.
2022-06-15 12:05:30 -07:00
Pierre Wendling
6b4b6d8e59
Test: Add Asin tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
43f6983a24
Test: Add Acos tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
95f6edb9a5
Test: Refactor trigonometric tests into a helper.
...
The precision test of these functions need a special helper, it can also
be used for their arc functions down the line.
2022-06-15 12:05:30 -07:00
Pierre Wendling
3b9f47b85f
Test: Remove early return in pow test.
2022-06-15 12:05:30 -07:00
Pierre Wendling
6be430c7f7
Test: Add Tan tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
af79b46f9e
Test: Add Sin tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
b06eda55e9
Test: Fix math suite build on Win32.
...
The cosine precision test now uses an array of double and the result
gets truncated instead of casted to signed int64.
2022-06-15 12:05:30 -07:00
Pierre Wendling
adb445eafb
Test: Add Cos tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
a864180cf3
Test: Add float header for FLT_RADIX definition.
2022-06-15 12:05:30 -07:00
Pierre Wendling
7a55fa4e56
Test: Add Scalbn tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
afd812374f
Test: Add Sqrt tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
c389c32d30
Test: Change assertion type in range tests.
...
Changes SDLTest_AssertPass(...) to SDLTest_AssertCheck(SDL_FALSE, ...)
for failed assertions so the internal counter gets updated properly.
2022-06-15 12:05:30 -07:00
Pierre Wendling
5ecc75a4fc
Test: Add Pow tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
6349ad7319
Test: Add Log10 tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
7041bbaf00
Test: Add Log tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
dd30ff2e31
Test: Add Exp tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
aacb5e1774
Test: Extract range test parameters into defines.
2022-06-15 12:05:30 -07:00
Pierre Wendling
75b9aab6c1
Test: Add Fmod tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
0dbdf90e7b
Test: Use SDLCALL in typedefs instead of ifdefs.
...
Thanks to @sezero for the tip.
2022-06-15 12:05:30 -07:00
Pierre Wendling
2ec48b36ba
Test: Fix OS/2 compilation in math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
43c22e5d1e
Test: Refactor math suite duplicate code.
...
Many tests were using the same underlying routine, as such three helper
functions were added:
- A wrapper to test double -> double functions.
- A wrapper to test (double, double) -> double functions,
- A wrapper for range tests on double -> double functions.
2022-06-15 12:05:30 -07:00
Pierre Wendling
3d720ba381
Test: Refactor math suites edge cases.
...
Split infinity and zero checks in their own functions.
The result of NAN tests is now logged.
The SDL_TestCaseReference structure were renamed to be more explicit.
2022-06-15 12:05:30 -07:00
Pierre Wendling
a530fc9199
Test: Add Copysign tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
48a406db4d
Test: Add Fabs tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
2130dff0fc
Test: Add Round tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
324b96153f
Test: Add Trunc tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
b09266a4ef
Test: Add Ceil tests to math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
9eb09d2392
Test: Refactored and formatted math test suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
e64acb619a
Test: Fix for-loop for OS/2 in math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
a3a852e912
Test: Unrolled the array of cases in math suite.
...
On OS/2, `INFINITY` is a `const double` which cannot be used to
instantiate an array.
2022-06-15 12:05:30 -07:00
Pierre Wendling
c23216bf46
Test: Removed static from local variables (Math).
...
Static would break compilation on OS/2.
2022-06-15 12:05:30 -07:00
Pierre Wendling
6646edf692
Test: Fix Windows build for math suite.
2022-06-15 12:05:30 -07:00
Pierre Wendling
7389eba943
Test: Fix C89 declaration and math include.
2022-06-15 12:05:30 -07:00