Commit Graph

1668 Commits

Author SHA1 Message Date
Ryan C. Gordon 9b8c5f642f
testaudio: Better fix for NULL dereference.
This code already handled NULL fine, it just got wrapped in a SDL_strdup call
in e23257307e, so make that SDL_strdup check for
NULL first.
2024-06-27 17:24:49 -04:00
Ryan C. Gordon 5631c6dbaa
testaudio: Don't crash if SDL_GetAudioDeviceName() returns NULL.
It definitely will for default devices, so this crash is real, but it's also
good defensive coding if something blows up unexpectedly.

Fixes #10130.
2024-06-27 17:20:11 -04:00
Ryan C. Gordon 982feb7a65 vulkan: SDL_Vulkan_CreateSurface now returns the usual int (0=ok, -1=error).
Fixes #10091.
2024-06-27 15:25:10 -04:00
Sam Lantinga def7a43a2e SDL_HINT_IME_SHOW_UI defaults to SDL_TRUE
This hint is currently only used on Windows, and this matches the behavior of other platforms.
2024-06-24 20:32:03 -07:00
Sam Lantinga 382494eeda checkkeys: draw the IME composition text 2024-06-24 20:32:03 -07:00
Sam Lantinga 92b3ce20b1 checkkeys: don't toggle text input with the left mouse button
This often gets triggered when clicking back and forth between the language bar and the application
2024-06-24 20:32:03 -07:00
Sam Lantinga 01ae067504 checkkeys: print the start/length values of the SDL_EVENT_TEXT_EDITING event 2024-06-24 20:32:03 -07:00
Sam Lantinga 94ae4e1513 Fixed build warnings 2024-06-24 13:36:56 -07:00
Sam Lantinga 0ff5c05486 Added SDL_GetWindows() 2024-06-24 12:22:12 -07:00
Sam Lantinga 2f5b20fcb5 Updated based on feedback from @JKaniarz 2024-06-24 11:49:15 -07:00
Sam Lantinga a938e2b979 Replaced test framework random code with SDL random functions 2024-06-24 11:49:15 -07:00
Sam Lantinga 96f2f23240 Simplified SDL random function names and added thread-safe versions 2024-06-24 11:49:15 -07:00
Sam Lantinga 138eb8649d checkkeys: draw a blinking cursor 2024-06-24 11:20:08 -07:00
Sam Lantinga 505badb7af checkkeys: added support for multiple windows 2024-06-24 11:20:08 -07:00
Sam Lantinga 76631a0978 The text input state has been changed to be window-specific.
SDL_StartTextInput(), SDL_StopTextInput(), SDL_TextInputActive(), SDL_ClearComposition(), and SDL_SetTextInputRect() all now take a window parameter.

This change also fixes IME candidate positioning when SDL_SetTextInputRect() is called before SDL_StartTextInput(), as is recommended in the documentation.
2024-06-24 11:20:08 -07:00
Sam Lantinga 258ee05655 checkkeys: enable showing IME candidates 2024-06-24 11:20:08 -07:00
Simon McVittie 2cfeff1505 testevdev: Associate HID reports for pedals with their other test data
This is how these globals were intended to have been used, similar to
what we already did for the Fanatec device.

Fixes: 3772d6cc "testevdev: Add raw HID report descriptors where available"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-24 04:39:34 -07:00
Simon McVittie 3150fdc75e Revert "testevdev.c: comment out two unused data to fix build."
This reverts commit e4f53e6b21.
We'll use these in the next commit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-24 04:39:34 -07:00
Anonymous Maarten 2018882bf2 testmanymouse: enable raw keyboard events on Windows 2024-06-22 11:35:00 -07:00
Anonymous Maarten 99d28ca485 testmanymouse: fix argument parsing 2024-06-22 14:43:06 +02:00
Sam Lantinga 90034b16dc The keycode in key events is affected by modifiers by default.
This behavior can be customized with SDL_HINT_KEYCODE_OPTIONS.
2024-06-22 00:19:06 -07:00
Sam Lantinga 0dd579d40d Removed SDL_Keysym 2024-06-21 22:06:08 -07:00
Sam Lantinga 679e4471ed Added the ability to query the keymap for keycodes based on modifier state 2024-06-21 22:06:08 -07:00
Sam Lantinga ef9bd8b609 Add the raw platform specific key code to SDL_Keysym
This allows applications to handle keys that SDL doesn't recognize, in a platform dependent way.

Fixes https://github.com/libsdl-org/SDL/issues/6390
2024-06-21 22:06:08 -07:00
Sam Lantinga 9d816c72ef Updated SDL3 scancode list
This adds more app editing and audio control keys and removes keys that launch applications

Work in progress on https://github.com/libsdl-org/SDL/issues/6390
2024-06-21 22:06:08 -07:00
Simon McVittie 53eff7f903 testevdev: Add X-Box One S controller via xpadneo 0.9.x
This is an out-of-tree driver providing an alternative interface to
X-Box gamepads. Compared with the in-kernel driver, it adds four
pseudo-buttons used to indicate which profile is active, and an
optional "misc" axis that combines the two triggers into a rudder.

Partially addresses libsdl-org/SDL#7823

Thanks: @kakra
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:05:26 -07:00
Simon McVittie 2804f92eff testevdev: Add missing device ID for Wiimote Classic Controller
Thanks: Jeremy Whiting
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:04:56 -07:00
Simon McVittie c244eb937b testevdev: Add the virtual X360 controller created by Steam Input
Thanks: Robert Beckett
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:02:23 -07:00
Simon McVittie f471392e73 testevdev: Add test data from Steam Deck built-in devices
Thanks: Robert Beckett
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:02:23 -07:00
Simon McVittie 740850d3ce testevdev: Add a field for the USB device version
For some devices, such as the Steam Deck's built-in Steam Controller,
the version number reported via evdev and the version number reported
via USB are different. We don't currently use this information anyway,
but in case we want to use it in the future, let's include it in our
test data.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:02:23 -07:00
Anonymous Maarten 0f27686a51 tests: run tests under a minimal debugger that can create minidumps
Tests on ci are run using this dumper, and will upload the minidumps.
2024-06-21 12:39:11 +02:00
Frank Praznik 2f276a2eea video: Expose HDR metadata per-window
Moves the HDR properties from the display to be per-window, and adds the frog_color protocol to enable HDR under Wayland.
2024-06-20 15:55:07 -04:00
Anonymous Maarten 72d5f39e5c Make testnative (on win32) UNICODE compatible 2024-06-20 15:40:32 +02:00
Anonymous Maarten 992f80eb51 testnative: include SDL_build_config.h instead of SDL_internal.h 2024-06-20 15:40:32 +02:00
John Kaniarz 38cac043af Added algorithm comments to SDL_rand_*() 2024-06-19 17:00:58 -07:00
John Kaniarz 8f29f8cae5 Renamed SDL_rand() to SDL_rand_bits() and updated tests 2024-06-19 17:00:58 -07:00
Hubert Maier 3acdb8a90b
JANITORIAL: Fix typos in comments in various files (#10058) 2024-06-19 07:13:46 -07:00
Sam Lantinga d7391394d3 Switched the camera format to use framerate ratio instead of interval ratio
This is more intuitive for game developers and users.

Fixes https://github.com/libsdl-org/SDL/issues/9896
2024-06-18 07:39:52 -07:00
Sam Lantinga 3a68febedf Enable HIDAPI controller support on mobile platforms 2024-06-17 15:05:12 -07:00
Sam Lantinga aeea819494 Added colorspace to SDL_CameraSpec 2024-06-16 17:47:16 -07:00
Sam Lantinga d1d484ddbe Added SDL_srand(), SDL_rand(), and SDL_rand_r() (thanks @JKaniarz!)
These are simple random functions that should not be used for serious random number generation.

Fixes https://github.com/libsdl-org/SDL/issues/4968
2024-06-16 07:41:00 -07:00
Sam Lantinga e388e377aa audio: Refer to audio devices to "playback" and "recording" 2024-06-15 08:00:33 -07:00
Ryan C. Gordon 38f0214e8a audio: Refer to audio devices to "playback" and "recording".
Fixes #9619.
2024-06-15 01:08:12 -04:00
Ryan C. Gordon 5bc654aad3
camera: SDL_GetCameraDeviceName() now follows the SDL_GetStringRule. 2024-06-13 18:13:51 -04:00
Ryan C. Gordon 9d3d893322
testcamera: Report device name and SDL camera driver in the window title. 2024-06-13 17:05:47 -04:00
Sam Lantinga 9f984e6fb4 testcontroller: fixed showing analog axis values 2024-06-12 22:27:54 -07:00
Sam Lantinga 80a907e0e6 Backed out the viewport and cliprect changes in 9fb5a9ccac
This ended up being lots of application code churn without any real benefit in practice.
2024-06-12 19:25:15 -07:00
Sam Lantinga 3e70376bce Enabled HIDAPI debug logging for diagnostic purposes 2024-06-12 15:03:41 -07:00
Sam Lantinga 9fb5a9ccac Use floating point values for viewport, clip rectangle, and texture sizes
These are integer values internally, but the API has been changed to make it easier to mix other render code with querying those values.

Fixes https://github.com/libsdl-org/SDL/issues/7519
2024-06-12 10:18:39 -07:00
Anonymous Maarten 32907a9606 Rename SDL_Swap(16|32|64)(LE|BE) to SDL_Swap(LE|BE)(16|32|64) 2024-06-12 02:29:39 +02:00
Sam Lantinga 391a63f29f Check raw keyboard input in checkkeys 2024-06-11 09:09:30 -07:00
Sam Lantinga ed5993d1cb Removed unused variable 2024-06-10 15:01:41 -07:00
Sam Lantinga 0cc61b27a2 SDL takes care of handling mouse relative mode on focus change 2024-06-10 14:57:32 -07:00
Sam Lantinga 3e018517c3 Fixed build errors after SDL_IOWhence change 2024-06-09 11:52:04 -04:00
Sam Lantinga 1938d25b7e Use "%S" format specifier for wide-character strings 2024-06-06 10:59:15 -07:00
Hunter Kvalevog 14f7eebac6 testcamera: Add [--camera name] parameter 2024-06-04 16:24:27 -07:00
Sam Lantinga 4d392bfc67 Fixed camera capture on iOS
My phone captured 1920x1080 images even though the highest reported format was higher resolution, so I adjusted testcamera to be able to handle different sized images than expected.

Fixes https://github.com/libsdl-org/SDL/issues/9930
2024-06-04 11:34:39 -07:00
Sam Lantinga 60396971ce Move the main header with SDL_MAIN_USE_CALLBACKS 2024-06-04 10:42:44 -07:00
Sam Lantinga a0d1445ccb Replaced SDL_GetRendererInfo() with SDL_GetRendererName()
The texture formats are available via the SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER property

Fixes https://github.com/libsdl-org/SDL/issues/9851
2024-06-03 21:10:58 -07:00
Semphris 8c8ee2174d Dialog: Add filter number, remove NULL termination 2024-06-03 18:22:26 -07:00
Sam Lantinga 1d83b782b8 Set the headphones to 50% volume to avoid blasting people's ears
Also fixed audio routing comments
2024-06-03 17:28:32 -07:00
Sam Lantinga 8aa7910184 Added an example of setting PS5 controller audio routing
Closes https://github.com/libsdl-org/SDL/pull/9661
2024-06-03 17:24:36 -07:00
Anonymous Maarten a919774fe4
Build with -Wfloat-conversion + fix all warnings 2024-06-03 21:33:29 +00:00
Ryan C. Gordon e23257307e Introduce formal policy for APIs that return strings.
This declares that any `const char *` returned from SDL is owned by SDL, and
promises to be valid _at least_ until the next time the event queue runs, or
SDL_Quit() is called, even if the thing that owns the string gets destroyed
or changed before then.

This is noted in the headers as "the SDL_GetStringRule", so this will both be
greppable to find a detailed explaination in docs/README-strings.md and
wikiheaders will automatically turn it into a link we can point at the
appropriate documentation.

Fixes #9902.

(and several FIXMEs, both known and yet-undocumented.)
2024-06-03 14:20:49 -04:00
Ryan C. Gordon 9a9a3d1a33 SDL_SystemCursor: rename enum items to match CSS.
Fixes #9079.
2024-06-01 22:32:43 -04:00
Anonymous Maarten 6896c4c3bf tests: testcases accept a void pointer argument 2024-05-31 19:18:24 +02:00
Anonymous Maarten d5060423a2 testplatform: fix leak at exit time
A leak was present at exit time on the Emscripten platform
2024-05-31 18:53:36 +02:00
Ryan C. Gordon 3364aff757
main: Make the main callback return value symbols smaller (thanks, @Lzard!).
Reference #9901.
2024-05-27 16:03:45 -04:00
L zard 06aa02453a Tests: Use the main callback code macros 2024-05-27 09:22:07 -07:00
Sam Lantinga 99599d9236 Added SDL_AddTimerNS() 2024-05-27 07:57:33 -07:00
Sam Lantinga b6360516e4 Added the timerID to the SDL timer callback
Fixes https://github.com/libsdl-org/SDL/issues/2593
2024-05-27 07:57:33 -07:00
Sam Lantinga df25e4022d Removed short aliases for 16-bit pixel formats
These were potentially misleading in the same way the RGB888/BGR888 aliases were

Fixes https://github.com/libsdl-org/SDL/issues/4994
2024-05-27 07:24:46 -07:00
Ryan C. Gordon cf2874080f mouse: Move mouse button state from a Uint32 to a formal typedef.
Reference Issue #9812.
2024-05-26 13:23:21 -04:00
Ryan C. Gordon 0f0570b060 pen: Change a Uint32 bitfield into a typedef.
Reference Issue #9812.
2024-05-26 13:23:21 -04:00
Anonymous Maarten fefa47e409 dropfile: main callbacks need extra CMake care on UWP 2024-05-25 16:35:11 +02:00
Anonymous Maarten 78e25d4994 testdropfile: convert to use callbacks 2024-05-25 04:44:07 +02:00
Sam Lantinga 2461bd8648 Removed unnecessary float casts 2024-05-23 15:12:19 -07:00
Frank Praznik 888a45977d
tests: Check the usable bounds for centered window positioning
SDL now centers windows according to the usable display bounds, so the window centering test requires an update for the new behavior.
2024-05-21 12:26:40 -04:00
Anonymous Maarten d3d7c04bf8 testcamera: libSDL3_test destroys the window and renderer
This fixes a "DEBUG: Parameter 'renderer' is invalid" message when exiting testcamera.
2024-05-17 14:39:29 +02:00
Anonymous Maarten 690875d555 testiconv: free all memory to fix --trackmem 2024-05-17 14:39:29 +02:00
Anonymous Maarten 831c79d32f testatomic: destroy threads + free all memory at quit to fix --trackmem 2024-05-17 14:39:29 +02:00
Sam Lantinga 4609af618a Updated logging functions for SDL3 naming convention 2024-05-16 10:22:15 -07:00
Anonymous Maarten 88980aeb21 android+test: testcamera needs CAMERA permissions 2024-05-16 16:43:53 +02:00
Sam Lantinga 661f2fc1fc Removed the SDL_Version structure, moved SDL version to SDL.h
Inspired by https://github.com/libsdl-org/SDL/issues/9788
2024-05-15 10:43:31 -07:00
Frank Praznik df3fea87d6 wayland: Rework scale-to-display
This extends the display scaling mode to be global and work in terms of pixels everywhere, with the content scale value set on displays. The per-window property had some issues, and has been removed in favor of retaining only the global hint that changes all coordinates to pixel values, sets the content scale on the displays, and generally makes the Wayland backend behave similarly to Win32 or X11.

Some additional work was needed to fix cases where displays can appear to overlap, since Wayland desktops are always described in logical coordinates, and attempting to adjust the display positions so that they don't overlap can get very ugly in all but the simplest cases, as large gaps between displays can result.
2024-05-13 19:10:19 -04:00
Sam Lantinga 17520c2e6e Removed SDL_RendererFlags
The flags parameter has been removed from SDL_CreateRenderer() and SDL_RENDERER_PRESENTVSYNC has been replaced with SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER during window creation and SDL_PROP_RENDERER_VSYNC_NUMBER after renderer creation.

SDL_SetRenderVSync() now takes additional values besides 0 and 1.

The maximum texture size has been removed from SDL_RendererInfo, replaced with SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER.
2024-05-13 15:06:11 -07:00
Frank Praznik f4aca6866c test: Free clipboard data after calling SDL_GetClipboardText()
Clipboard allocations were being leaked in two instances.
2024-05-13 10:27:24 -04:00
Sam Lantinga c95c415a0b Fixed warning C4244: '=': conversion from 'SDL_Keymod' to 'Uint16', possible loss of data 2024-05-10 16:43:09 -07:00
Sam Lantinga c1ba31118b Added ball, touchpad, and sensor support for virtual joysticks
Fixes https://github.com/libsdl-org/SDL/issues/9542
2024-05-09 18:25:22 -07:00
Sam Lantinga bcbf09acde Renamed SDL_AttachVirtualJoystickEx() to SDL_AttachVirtualJoystick()
The shorthand version of this function didn't allow specifying a controller name, which seems pretty important. It seems like anyone actually implementing a virtual joystick is going to want to use some of the extended functionality.
2024-05-09 14:05:58 -07:00
Sam Lantinga 54fb629da5 SDL_WindowFlags is now 64-bit
Fixes https://github.com/libsdl-org/SDL/issues/7321
2024-05-09 10:39:54 -07:00
Frank Praznik 1f43c88220 time: Use a function instead of properties to retrieve the system date and time locale info
This allows applications to re-query the values if the system locale is changed during runtime, and better matches the other locale functions. A note is included in the documentation mentioning that this can be slow, as it has to call into OS functions.

Also allows for the removal of the init/quit time functions, as they are no longer needed.
2024-05-08 15:35:04 -04:00
Sam Lantinga aecb62e30d Improved API consistency for flag data types
Flag data types are always unsigned and have the valid values following the typedef.
2024-05-07 12:24:37 -07:00
Anonymous Maarten 9aff68746f cmake: add khronos include directories with PRIVATE visibility 2024-05-07 17:37:21 +02:00
Susko3 56feecc17d
Fix property cleanup callback not being called on error (#9663)
The documentation for `SDL_SetPropertyWithCleanup` mentions that the cleanup function
is called upon failure. But this wasn't working in the code.
2024-05-06 14:50:28 -07:00
Petar Popovic 45ac1a09d9 System dependent 64 bit integer suffixes
Added macros SDL_SINT64_C() and SDL_UINT64_C().
Integer suffixes of SDL_MAX_SINT64, SDL_MIN_SINT64, SDL_MAX_UINT64
and SDL_MIN_UINT64 are now system dependent.
2024-05-06 09:08:49 -07:00
Frank Praznik 3979ea8ed0 tests: Add a pointer warp test to testmouse
Press 'c' to center the pointer in the window using relative coordinates via SDL_WarpMouseInWindow().

Press alt+'c' to center the pointer in the window using global coordinates via SDL_WarpMouseGlobal().
2024-05-03 12:33:19 -04:00
Sam Lantinga 22016228ca Fixed build 2024-05-03 09:25:54 -07:00
Sam Lantinga db43a6b418 testcamera: open the camera using the highest framerate available 2024-05-02 12:27:20 -07:00
Sam Lantinga e6e1412e20 testcamera: create the texture as a streaming texture, since we'll update it every frame.
Also set the window size to the camera texture size
2024-05-02 11:40:28 -07:00
Semphris b9d3d746a0 Add trailing path separator to SDL_GetUserFolder() 2024-04-30 18:01:16 -07:00
Semphris c6a70d6898 Add support for modal windows to more platforms
- Adds support for modal windows to Win32, Mac, and Haiku, and enhances functionality on Wayland and X11, which previous set only the parent window, but not the modal state.
- Windows can be declared modal at creation time, and the modal state can be toggled at any time via SDL_SetWindowModalFor() (tested with UE5 through sdl2-compat).
- Allows dynamic unparenting/reparenting of windows.
- Includes a modal window test.
2024-04-30 13:47:57 -04:00
Sam Lantinga 0df12d223c Fixed crash cleaning up text
Text needs to be cleaned up before the renderer is freed.
2024-04-26 19:32:20 -07:00
Sam Lantinga 14f584a94b SDL_CreateWindowAndRenderer() takes the window title as the first parameter
Fixes https://github.com/libsdl-org/SDL/issues/9626
2024-04-25 20:00:14 -07:00
Petar Popovic e0b45fed06 testlock.c: replace function call kill with raise
Replacing function call `kill(0, SIGINT);` with `(void)raise(SIGINT);` in file test/testlock.c.
The `kill()` function is not available on Unix systems when compiling without system extensions enabled.
2024-04-25 15:11:08 -04:00
Frank Praznik 566d142938 tests: Clean up the renderer in the video test suite since it isn't automatic anymore. 2024-04-19 12:23:40 -04:00
Anonymous Maarten 911fc9b17e testffmpeg: treat Khronos headers as system headers 2024-04-18 09:10:15 -07:00
Sam Lantinga d51b53ef8f Add final Vulkan AV1 ext and VVC support
Fixes https://github.com/libsdl-org/SDL/issues/9464
2024-04-15 16:15:09 -07:00
Brick edaab8ad9f Refactored audio conversion to reduce copying
More of the logic has been moved into SDL_AudioQueue,
allowing data to be converted directly from the input buffer.
2024-04-15 11:47:18 -10:00
Brick ae57b0c9d8 Randomly split the data in audio_resampleLoss
This helps ensure correct resampling across track boundaries
2024-04-15 11:47:18 -10:00
Brick 8f6f9cadc4 Rewrote audio resampler using cubic filter interpolation
This allows using a much smaller (1.5 KB) lookup table, in exchange for a small amount of extra work per frame.

The extra work (a few extra loads/mul/adds) is negligible, and can execute in parallel.
The reduction in cache misses almost certainly outweighs any added cost.

The table is generated at runtime, and takes less than 0.02ms on my computer.
2024-04-15 11:47:18 -10:00
Brick f18cf7cffb Avoid changing dst_spec in testaudiostreamdynamicresample skip_audio
This is no longer allowed on bound streams
2024-04-15 11:47:18 -10:00
Sam Lantinga 43a59ffe45 Fixed crashes when a window has NULL driverdata 2024-04-15 10:15:10 -07:00
Cameron Cawley 723cbf4b8e testmouse: Create the window on the touch screen when building for the 3DS 2024-04-15 06:37:16 -10:00
Sylvain Becker 6b9a8f0da1 IOS: fix compilation of testautomation.app
only for IOS/TVOS, also disable testautomation_pen suite which requires sdl internals files
2024-04-15 03:28:16 -10:00
Petar Popovic edb370b8bb Fixing testffmpeg.c fallthrough warning 2024-04-15 03:27:42 -10:00
Semphris 0caa2828d5 Fixes for testdialog.c 2024-04-15 03:25:55 -10:00
Ryan C. Gordon d252a8fe12
joystick: SDL_VirtualJoystickDesc no longer takes a struct version.
If we need to extend this in the future, we'll make a second struct and
a second SDL_AttachVirtualJoystickEx-style function that uses it.

Just zero the struct and don't set a version.

Fixes #9489.
2024-04-13 14:16:12 -04:00
Ravbug 2d640d0b59
ci: Add iOS and tvOS CMake GitHub Actions checks (#9465)
- Also add watchos support to CMake (SDL does not support this platform yet)

Co-authored-by: Ravbug <ravbug@users.noreply.github.com>
Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
2024-04-08 19:18:28 +02:00
Petar Popovic 764fe72449 SDL_time.h: Renaming enums SDL_DATE_FORMAT and SDL_TIME_FORMAT to SDL_DateFormat and SDL_TimeFormat 2024-04-07 23:03:01 -04:00
Sam Lantinga 5fa87e29e7 Removed SDL_RENDERER_ACCELERATED and SDL_RENDERER_SOFTWARE
These flags are unnecessary and have always been a source of confusion.
2024-04-04 13:30:49 -07:00
Ryan C. Gordon bc94451bed
testfilesystem: Add a '?' to the glob test, for a little more completeness. 2024-04-04 10:44:19 -04:00
Sam Lantinga 0abdc1a343 Renamed GLOBDIR to GLOB 2024-04-04 07:40:48 -07:00
Ryan C. Gordon 764207d873 filesystem: Added SDL_GlobDirectory() and SDL_GlobStorageDirectory().
Fixes #9287.
2024-04-04 09:40:13 -04:00
Sam Lantinga a82ed82bc7 SDL_QueryTexture() fills in a pointer to SDL_PixelFormatEnum 2024-04-01 15:45:22 -07:00
Sam Lantinga 8847b35244 Separate joystick power state into battery status and percentage
This allows you to see battery percentage while the controller is charging
2024-04-01 13:59:00 -07:00
Anonymous Maarten 72cf9c0ef4 test: don't run testautomation in parallel 2024-03-29 21:11:35 +01:00
Ryan C. Gordon 38e3c6a4aa
main: Add an optional `appstate` param to main callback entry points.
This allows apps to maintain state data without using global variables.

Fixes #9377.
2024-03-27 17:22:08 -04:00
Frank Praznik a7df28201b Revert "testautomation: fix renderer leak in video tests"
This reverts commit 2f13f66c71.

Not needed if renderers are once again implicitly cleaned up when their associated windows are destroyed.
2024-03-26 13:10:14 -07:00
Sam Lantinga f1f24b173c Added support for multiple distinct keyboards 2024-03-25 20:41:05 -07:00
Anonymous Maarten a65982e15d testevdev: include SDL_internal.h first, and fixup SDL_main.h 2024-03-26 00:10:40 +01:00
Cameron Gutman f14fb979c1 Remove legacy SDL2 input grab API 2024-03-24 16:53:23 -07:00
Christoph Reichenbach 0df0462d0a Removed all tabs in testautomation_pen.c 2024-03-24 05:05:30 -07:00
Christoph Reichenbach 615c7efd98 Fix #9279: Memory leak in pen name handling
- Fixes a leak in pen name allocation that would trigger
  for both X11 and Wayland for some non-pen input devices
  when new devices are added/removed.
- SDL_PenQuit() now deallocates and resets the table of known pens
- testautomation_pen.c now uses PenInit and PenQuit as setup and
  teardown, respectively

testautomation_pen.c was already triggering the leak, and it is
visible with --trackmem, so no new tests are added.
2024-03-24 05:04:53 -07:00
Anonymous Maarten 89b135e570 cmake: add automation and platform test without simd 2024-03-23 16:36:44 -07:00
Sam Lantinga 208cd434b5 Show the names of mice and keyboards when they connect 2024-03-23 16:31:00 -07:00
Sam Lantinga 6604d423fd Added a test program for multiple mice 2024-03-23 16:31:00 -07:00
Sam Lantinga d1eb4adb16 Be explicit about the event mouse and keyboard ID 2024-03-23 16:31:00 -07:00
Sam Lantinga 2fe1a6a279 Initial support for hotplugging mice and keyboards 2024-03-23 16:31:00 -07:00
Anonymous Maarten 75a71bde4b cmake: build tests against installed SDL prefix 2024-03-23 21:41:20 +01:00
Anonymous Maarten 7f888f98f7 gles2: only build tests when building SDL3 or when the headers are available 2024-03-23 21:41:20 +01:00
Anonymous Maarten c493b40cc3 testffmpeg_vulkan: fix -Wincompatible-pointer-types warning
```
[1/1] Building C object test/CMakeFiles/testffmpeg.dir/testffmpeg_vulkan.c.o
/src/SDL/test/testffmpeg_vulkan.c: In function ‘BeginVulkanFrameRendering’:
/src/SDL/test/testffmpeg_vulkan.c:787:20: warning: passing argument 1 of ‘vk->lock_frame’ from incompatible pointer type [-Wincompatible-pointer-types]
  787 |     vk->lock_frame(frames, pVkFrame);
      |                    ^~~~~~
      |                    |
      |                    AVHWFramesContext *
/src/SDL/test/testffmpeg_vulkan.c:787:20: note: expected ‘struct AVHWFramesContext *’ but argument is of type ‘AVHWFramesContext *’
/src/SDL/test/testffmpeg_vulkan.c: In function ‘FinishVulkanFrameRendering’:
/src/SDL/test/testffmpeg_vulkan.c:885:22: warning: passing argument 1 of ‘vk->unlock_frame’ from incompatible pointer type [-Wincompatible-pointer-types]
  885 |     vk->unlock_frame(frames, pVkFrame);
      |                      ^~~~~~
      |                      |
      |                      AVHWFramesContext *
/src/SDL/test/testffmpeg_vulkan.c:885:22: note: expected ‘struct AVHWFramesContext *’ but argument is of type ‘AVHWFramesContext *’
```
2024-03-22 11:05:13 -07:00
Sam Lantinga 18feaa52dd Fixed comment at the top of testtime.c 2024-03-19 17:09:08 -07:00
Sam Lantinga e0ef4dac85 Fixed int to float conversion warnings 2024-03-19 17:07:52 -07:00
Sam Lantinga 3316587113 Fixed warning C4389: '==': signed/unsigned mismatch 2024-03-19 17:04:29 -07:00
Frank Praznik a6fbf0488c Add time and realtime clock functions
Adds functions to query the system's realtime clock, convert time intervals to/from a calendar date and time in either UTC or the local time, and perform time related calculations.

An SDL_Time type (a time interval represented in nanoseconds), and SDL_DateTime struct (broken down calendar date and time) were added to facilitate this functionality.

Querying the system time results in a value expressed in nanoseconds since the Unix epoch (Jan 1, 1970) in UTC +0000. Conversions to and from the various platform epochs and units are performed when required.

Any direct handling of timezones and DST were intentionally avoided. The offset from UTC is provided when converting from UTC to a local time by calculating the difference between the original UTC and the resulting local time, but no other timezone or DST information is used.

The preferred date formatting and 12/24 hour time for the system locale can be retrieved via global preferences.

Helper functions for obtaining the day of week or day or year for calendar date, and getting the number of days in a month in a given year are provided for convenience. These are simple, but useful for performing various time related calculations.

An automated test for time conversion is included, as is a simple standalone test to display the current system date and time onscreen along with a calendar, the rendering of which demonstrates the use of the utility functions (press up/down to increment or decrement the current month, and keys 1-5 to change the date and time formats).
2024-03-19 10:57:36 -07:00
Anonymous Maarten f59dbf6a12 cmake: add -Wimplicit-fallthrough warning 2024-03-18 20:34:50 +01:00
Sam Lantinga a1a0156756 Renamed SDL_SizeIO() SDL_GetIOSize() 2024-03-18 00:27:18 -04:00
Sam Lantinga df0f5deddf Added SDL_IOFromDynamicMem() 2024-03-18 00:27:18 -04:00
Sam Lantinga d65ae710a1 Renamed SDL_LogGetOutputFunction() and SDL_LogSetOutputFunction() to match SDL 3.0 naming convention 2024-03-17 12:28:11 -07:00
Petar Popovic 4ecea42fb0 testautomation_math.c: use isinf(V) instead of fpclassify(V) == FP_INFINITE
Using fpclassify can cause a linker error.
Using isinf instead fixes this.
2024-03-17 11:12:09 -07:00
Sam Lantinga 7a088527c1 Removed the reserved parameter from SDL_EnumerateDirectoryCallback
If someone needs to, say, include an SDL_Storage object, they can simply point userdata at a structure that includes the the storage and any other data needed in enumeration.
2024-03-17 08:39:43 -07:00
Sam Lantinga db0c1d7aeb Added portable file and directory operations (thanks @icculus!) 2024-03-17 08:39:43 -07:00
Anonymous Maarten e5812a9fd2 testpen: don't include math.h 2024-03-16 20:37:31 +01:00
Anonymous Maarten 2f13f66c71 testautomation: fix renderer leak in video tests 2024-03-16 11:59:04 -07:00
Anonymous Maarten db31367999 testffmpeg: use SDL_free instead of free 2024-03-15 21:26:40 +01:00
Anonymous Maarten f8c2ec5462 testffmpeg: use Uint64 instead of __u64 2024-03-15 21:26:40 +01:00
Ryan C. Gordon 5a21d87e69
rwops: Changed filenames that reference "rwops" to "iostream". 2024-03-14 23:30:59 -04:00
Ryan C. Gordon fc7afa9cbf
rwops: Renamed SDL_RWops to SDL_IOStream, and other related symbols. 2024-03-14 19:38:12 -04:00
Ryan C. Gordon 7d4d8ccde0
rwops: Rename everything from SDL_RWxxx to SDL_XxxRW. 2024-03-14 19:37:04 -04:00
Ryan C. Gordon 655ceb3b31
rwops: Renamed SDL_CreateRW and SDL_DestroyRW to SDL_OpenRW and SDL_CloseRW. 2024-03-14 19:37:01 -04:00
Ryan C. Gordon 525919b315
rwops: Reworked RWops for SDL3.
- SDL_RWops is now an opaque struct.
- SDL_AllocRW is gone. If an app is creating a custom RWops, they pass the
  function pointers to SDL_CreateRW(), which are stored internally.
- SDL_RWclose is gone, there is only SDL_DestroyRW(), which calls the
  implementation's `->close` method before freeing other things.
- There is only one path to create and use RWops now, so we don't have to
  worry about whether `->close` will call SDL_DestroyRW, or if this will
  risk any Properties not being released, etc.
- SDL_RWFrom* still works as expected, for getting a RWops without having
  to supply your own implementation. Objects from these functions are also
  destroyed with SDL_DestroyRW.
- Lots of other cleanup and SDL3ization of the library code.
2024-03-14 19:36:08 -04:00
Semphris 70c2e15615 Add file dialogs 2024-03-14 15:40:25 -07:00
Sam Lantinga 209a87bf24 Added missing default case (thanks @sezero!) 2024-03-14 08:52:59 -07:00
Sam Lantinga 41b7036f37 testffmpeg: added support for EGL OES frame formats 2024-03-12 16:13:04 -07:00
Sam Lantinga d78a24a5ce testffmpeg: added verbose logging of ffmpeg messages 2024-03-11 15:48:52 -07:00
Sam Lantinga 7c5f79e7ea testffmpeg: removed redundant enumeration of hardware device types 2024-03-11 15:31:47 -07:00
Anonymous Maarten bee8a95571 Fix SDL_LEAN_AND_MEAN build 2024-03-11 13:46:16 -07:00
Sam Lantinga efbbafb3f1 Re-added balls to the SDL joystick API
It turns out these were being used on Linux and at least one virtual driver was making use of them (thanks @mrfixit2001!)
2024-03-10 21:30:14 -07:00
Nour Fouad b6c5ad0075 Update hardcoded value of pi to use SDL constant SDL_PI_F for improved consistency and readability. 2024-03-08 20:49:01 -08:00
Sam Lantinga fcb132b8e8 Allow building testffmpeg without Vulkan support 2024-03-08 16:45:27 -08:00
Ozkan Sezer d86ff6c6c0 remove stale / wrong information from SDL_RWread() documentation 2024-03-08 18:55:40 +03:00
Sam Lantinga e9ab2d46de Revert "Change `SDL_Keycode` type to an enum"
SDL_Keycode can actually be any printable character on the keyboard, so isn't limited to the enumerated values of SDL_KeyCode.
2024-03-07 06:58:43 -08:00
Sam Lantinga 33eaddc565 Cleaned up various type conversion issues
This makes sure SDL_PixelFormatEnum flows through the internal code correctly, as well as fixing a number of other minor issues.
2024-03-07 06:58:43 -08:00
Susko3 01248a99c8 Add `default: break;` to switches on SDL_Event::type
This is just a nice-to-have, as `SDL_Event::type` in an `Uint32`, so there are no
compiler errors about not handling all `SDL_EventType` enum values.
2024-03-06 15:40:05 -08:00
Susko3 641b911d38 Update some internal files to use `SDL_WindowFlags` 2024-03-06 15:08:12 -08:00
Susko3 424616e032 Use SDL_PixelFormatEnum as type 2024-03-06 15:02:13 -08:00
Susko3 f8cb3c742d Change `SDL_Keycode` type to an enum 2024-03-06 12:17:53 -08:00
Sam Lantinga c07b39fa06 Fixed build 2024-03-06 09:57:39 -08:00
Sam Lantinga 860155680d SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events. 2024-03-06 09:51:15 -08:00
Sam Lantinga 9db68f97f9 Reverted SDL_Vulkan_GetInstanceExtensions() API change
This function is commonly used with Vulkan structures that use uint32_t, so we should keep the Uint32 signature.
2024-03-05 13:39:42 -08:00
Sylvain cea717e5d3 Removed some uneeded 'unsigned': renderer.num_texture_format and SDL_Vulkan_GetInstanceExtensions() prototype 2024-03-05 13:31:28 -08:00
Sam Lantinga d4f4aa745a Use C++ style comments in new code 2024-03-05 04:46:37 -08:00
Sam Lantinga fb87f8f15c testffmpeg: fixed mismatch between frame size and frame texture size
The AVHWFramesContext associated with the frame has the texture size, and the frame width and height are the displayed size and can be smaller than the texture size
2024-03-04 11:17:42 -08:00
Sam Lantinga 180dd0bb39 testffmpeg: don't free the instance extensions, we hold onto them in the context 2024-03-04 11:17:42 -08:00
Sam Lantinga 2d4105ba8b testffmpeg: only enable AV_PIX_FMT_VULKAN if we have a Vulkan renderer 2024-03-04 11:17:42 -08:00
Sam Lantinga 97f97109d1 testffmpeg: fixed Vulkan validation errors
The semaphores need to be submitted in order
2024-03-04 09:29:36 -08:00
Sam Lantinga dbec2150d0 testffmpeg: added support for Vulkan rendering 2024-03-04 09:29:36 -08:00
Robert Edmonds a4d7ff6751 testffmpeg: Use EGL_EXT_image_dma_buf_import_modifiers extension
If the `EGL_EXT_image_dma_buf_import_modifiers` extension is available, propagate the DRM format modifier from the AVDRMObjectDescriptor to eglCreateImage() on Linux. Some hardware will decode video into a non-linear DRM surface, and passing the DRM format modifier to eglCreateImage() is required in order to display something useful.

Fixes https://github.com/libsdl-org/SDL/issues/9075
2024-03-03 15:18:56 -08:00
Sam Lantinga 88dcf74588 testyuv: we no longer need to override the HDR headroom for the BT.2020 test 2024-03-02 15:06:28 -08:00
Sam Lantinga 7f9ff6277c Don't assume HDR headroom for HDR10 surfaces
Applications that support HDR will set the correct values for their content.
2024-03-02 15:02:17 -08:00
Sam Lantinga f2cd361e25 testyuv: added validation of P010 YUV format
Also added conversion between RGB and P010, using XRGB2101010 as a bridging format in PQ space
2024-03-01 20:26:52 -08:00
Sam Lantinga 47be24d225 testyuv: added --monochrome and --luminance options for interactive mode 2024-03-01 07:42:34 -08:00
Sam Lantinga 991ad27de8 testyuv: added GetColorspaceForYUVConversionMode() 2024-03-01 07:42:34 -08:00
Ryan C. Gordon 1e8b006d43 stdlib: qsort and bsearch changes.
- Always use internal qsort and bsearch implementation.
- add "_r" reentrant versions.

The reasons for always using the internal versions is that the C runtime
versions' callbacks are not mark STDCALL, so we would have add bridge
functions for them anyhow, The C runtime qsort_r/qsort_s have different
orders of arguments on different platforms, and most importantly: qsort()
isn't a stable sort, and isn't guaranteed to give the same ordering for
two objects marked as equal by the callback...as such, Visual Studio and
glibc can give different sort results for the same data set...in this
sense, having one piece of code shared on all platforms makes sense here,
for reliabillity.

bsearch does not have a standard _r version at all, and suffers from the
same SDLCALL concern. Since the code is simple and we would have to work
around the C runtime, it's easier to just go with the built-in function
and remove all the CMake C runtime tests.

Fixes #9159.
2024-03-01 08:28:12 -05:00
Sam Lantinga 039144350c Be more precise about what we're testing in testyuv 2024-02-28 17:15:47 -08:00
Sam Lantinga b30ba1c5d4 Updated RGBtoYUV() to use the full YCbCr conversion formula 2024-02-28 16:58:39 -08:00
Sam Lantinga 353e76b40b Use the correct colorspace for yuv conversion tests 2024-02-28 10:03:18 -08:00
Sam Lantinga fb3bf1dcbd Fixed device queue initialization when render and present queue families are different 2024-02-28 08:55:56 -08:00
Anonymous Maarten 0a961915dc cmake: testffmpeg requires link to EGL library for EGL feature 2024-02-27 12:28:06 +01:00
Sam Lantinga 24e021c67e testffmpeg: refactored texture creation properties into a single function 2024-02-26 16:01:23 -08:00
Sam Lantinga ff18d7cfa0 testffmpeg: added pixel format mapping for NV12 and NV21 2024-02-26 15:52:21 -08:00
Sam Lantinga f99143f437 Don't quit testffmpeg when alt-tabbing away 2024-02-26 15:21:26 -08:00
Sam Lantinga 3a796c9722 Allow specifying the render driver in the environment for testffmpeg 2024-02-26 15:13:10 -08:00
Sam Lantinga dc9a3c83e2 Use the mastering display metadata to do proper tone mapping for HDR content 2024-02-26 14:20:34 -08:00
Sam Lantinga 141497b14f Added an automated test to verify clip rect functionality 2024-02-25 09:44:41 -08:00
Sam Lantinga 4ba6aeee9d A second take on HDR support with an SDR white point and HDR headroom
This better reflects how HDR content is actually used, e.g. most content is in the SDR range, with specular highlights and bright details beyond the SDR range, in the HDR headroom.

This more closely matches how HDR is handled on Apple platforms, as EDR.

This also greatly simplifies application code which no longer has to think about color scaling. SDR content is rendered at the appropriate brightness automatically, and HDR content is scaled to the correct range for the display HDR headroom.
2024-02-21 19:25:49 -08:00
Anonymous Maarten cbf0b1ce81 testcamera: create window and renderer through test library 2024-02-21 00:49:15 +01:00
Ryan C. Gordon f59c66a97f testcamera: Allow app to flip between a front and back camera. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon b1ed49772c camera: Replace testcamera.c with testcameraminimal.c 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 47313bba32 camera: SDL_GetCameraDevices should not report "no devices" like an error. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 0b8617f71d test: Fixed CMake to build testcameraminimal correctly on WinRT. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 67708f9110 camera: Emscripten support!
This also adds code to deal with waiting for the user to approve camera
access, reworks testcameraminimal to use main callbacks, etc.
2024-02-20 15:56:26 -05:00
Ryan C. Gordon 87e7046fca camera: Public API functions should say "Format" not "Spec" to match audio. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon d3e6ef3cc6 camera: Massive code reworking.
- Simplified public API, simplified backend interface.
- Camera device hotplug events.
- Thread code is split up so it backends that provide own threads can use it.
- Added "dummy" backend.

Note that CoreMedia (Apple) and Android backends need to be updated, as does
the testcamera app (testcameraminimal works).
2024-02-20 15:56:26 -05:00
Ryan C. Gordon cb10c80aaf camera: Reworked to operate with a driver interface, like other subsystems. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon 7ae955ce68 camera: Renamed everything from "video capture" to "camera", wired to CMake. 2024-02-20 15:56:26 -05:00
Ryan C. Gordon f49ce4a15d camera: Renamed "video_capture" files to "camera" and moved to own subdir. 2024-02-20 15:56:26 -05:00
Sam Lantinga ed615e92b7 Updated automated test now that getting an invalid property isn't an error 2024-02-17 09:30:50 -08:00
Sam Lantinga 202886f873 Make use of the HDR light range when playing HDR video 2024-02-16 20:05:11 -08:00
Sam Lantinga cb38649490 Added SDL_PROP_DISPLAY_HDR_WHITE_LEVEL_FLOAT 2024-02-16 19:50:41 -08:00
Sam Lantinga d451fcd7a7 Fixed HDR video content being too bright on Apple platforms
This probably isn't the exact formula that we need, but it's much closer to correct.
2024-02-15 16:39:13 -08:00
Sam Lantinga c09daf8388 Removed unused variables 2024-02-15 14:11:04 -08:00
Sam Lantinga 2f7c24e4be Removed SDL_HINT_RENDER_SCALE_QUALITY
Textures now default to linear filtering, use SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST) if you want nearest pixel mode instead.
2024-02-12 09:54:33 -08:00
Sam Lantinga 7cb1ca60ec Removed SDL_HINT_RENDER_OPENGL_SHADERS
Shaders are always used if they are available.
2024-02-12 09:54:33 -08:00
Sam Lantinga a538936821 Renamed SDL_HINT_LINUX_JOYSTICK_DEADZONES to SDL_HINT_JOYSTICK_LINUX_DEADZONES 2024-02-12 09:54:33 -08:00
Sam Lantinga 9ce7fe2848 Removed SDL_HINT_ACCELEROMETER_AS_JOYSTICK
Sensors are a first-class object in SDL and we haven't gotten any feedback that this feature is useful these days.

Closes https://github.com/libsdl-org/SDL/pull/7879
2024-02-12 09:54:33 -08:00
Sam Lantinga cacac6cc34 Updated structure and field names for consistency
Type names are camel case and field names are snake case except for fields ending in id, which are capitalized.

Fixes https://github.com/libsdl-org/SDL/issues/6955
2024-02-11 08:27:56 -08:00
Sam Lantinga f6b92c9b88 Re-added a simplified version of SDL_SetWindowShape()
In order to handle mouse click transparency this needs to be implemented inside SDL
2024-02-09 16:04:46 -08:00
Sam Lantinga 1143bdc351 Greatly simplified the shape example 2024-02-09 03:04:40 -08:00
Sam Lantinga 1c4c29b7ad Fixed a swap chain leak and a double-free in testffmpeg.c
Also added more debug logging to the direct3d11 renderer
2024-02-06 21:33:57 -08:00
Sam Lantinga 3158342441 Use SDL_Color for SDL_RenderGeometryRaw() and add SDL_RenderGeometryRawFloat()
Eventually we can re-add a fast path for that data down to the individual renderers. Setting color scale would still require converting to float, and most hardware accelerated renderers prefer to consume colors as float, so this requires some thought and performance testing.

Fixes https://github.com/libsdl-org/SDL/issues/9009
2024-02-06 18:16:41 -08:00
Sam Lantinga 8afba41aef Added support for HDR10 video on Apple platforms 2024-02-06 15:40:47 -08:00
Sam Lantinga 2039c46d2c Added support for creating an SDL texture from a CVPixelBufferRef 2024-02-06 15:40:47 -08:00
Sam Lantinga ba074acad4 Implemented scRGB colorspace and HDR support on macOS 2024-02-06 12:29:44 -08:00
Sam Lantinga 30e176d6ba Added HDR display properties and related event
Also added an HDR calibration stage to testcolorspace
2024-02-06 02:48:05 -08:00
Sam Lantinga d4caef5b89 Generalize SDR white level handling into a color scale
This gives applications better control over how and when light levels are adjusted when working with HDR content and display.
2024-02-06 02:48:05 -08:00
Sam Lantinga e74171b1ae Added support for HDR10 video playback on direct3d11
Fixes https://github.com/libsdl-org/SDL/issues/8053
2024-02-05 09:45:39 -08:00
meyraud705 f85535b4b6 Use functions from SDL instead of libc 2024-02-05 09:01:28 -05:00
Sam Lantinga ec322bee1c Fixed testyuv help message 2024-02-04 13:09:40 -08:00
Sam Lantinga 327b976bc4 SDL_COLORSPACE_JPEG is the default YUV colorspace 2024-02-04 13:09:40 -08:00
Sam Lantinga 5b8e5f8b9f Fixed accidental changing of All to Allu in previous commit (thanks @zturtleman!) 2024-02-03 23:46:22 -08:00
Sam Lantinga c0b27ccef9 Fixed warning C4701: potentially uninitialized local variable 'drawnTextRect' used 2024-02-03 11:49:15 -08:00
Sam Lantinga 8eba5b75ca Fixed warning C4701: potentially uninitialized local variable 'rndctx' used 2024-02-03 11:49:15 -08:00
Sam Lantinga 445cb42acd Fixed warning C4244: 'function': conversion from 'int' to 'Uint16', possible loss of data 2024-02-03 11:49:15 -08:00
Sam Lantinga 45f936c788 Fixed warning C4245: 'initializing': conversion from '__int64' to 'unsigned __int64', signed/unsigned mismatch 2024-02-03 11:49:15 -08:00
Sam Lantinga 74e85e3a51 Fixed warning C4706: assignment within conditional expression 2024-02-03 11:49:15 -08:00
Sam Lantinga c3e3ad6140 Fixed build warnings 2024-02-03 11:49:15 -08:00
Sam Lantinga c02aaebccc Fixed warning C4245: 'initializing': conversion from 'int' to 'Uint32', signed/unsigned mismatch 2024-02-03 11:49:15 -08:00
Sam Lantinga ff5fdf9f53 Fixed warning C4244: 'initializing': conversion from 'int' to 'const Uint8', possible loss of data 2024-02-03 11:49:15 -08:00
Sam Lantinga 9989f92eee Fixed warning C4245: 'initializing': conversion from 'int' to 'SDL_AudioDeviceID', signed/unsigned mismatch 2024-02-03 11:49:15 -08:00
Sam Lantinga 89b9d6cbdc SDL_RenderReadPixels() now returns a surface
Fixes https://github.com/libsdl-org/SDL/issues/8977
2024-02-03 11:49:15 -08:00
Sam Lantinga 50a805cdd1 Use YUV colorspaces instead of a global YUV conversion mode
Fixes https://github.com/libsdl-org/SDL/issues/8669
2024-02-03 07:36:18 -08:00
Sam Lantinga f9c57e16b0 Don't test 10-bit pixel format conversion
We either need to explicitly test using the sRGB colorspace or update the tests for HDR10 color conversion. We'll just disable them for now, as these formats aren't commonly used in games.
2024-02-02 18:24:15 -08:00
Sam Lantinga b8fe96fa81 Fixed build warning 2024-02-02 18:24:05 -08:00
Sam Lantinga 5d48f9a63a Added SDL_CopyProperties() 2024-02-02 15:09:12 -08:00
Sam Lantinga 9591b2cfb4 Finalized the SDL render API colorspaces
The renderer will always use the sRGB colorspace for drawing, and will default to the sRGB output colorspace. If you want blending in linear space and HDR support, you can select the scRGB output colorspace, which is supported by the direct3d11 and direct3d12
2024-02-02 13:13:53 -08:00
Simon McVittie 7c089f4e57 testautomation_math: Fix misleading log output
These originally checked for expected ± EPSILON as logged, but since
commit 880c6939 they check for expected ± max_err, where max_err may
need to be greater than EPSILON for very large expected results like
the ones in exp_regularCases().

Also, EPSILON is so small that the default precision of the %f format
(6 decimal places) would never actually have shown its effect, so log
it in scientific notation instead.

Fixes: 880c6939 "testautomation_math: do relative comparison + more precise correct trigonometric values"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-02 07:44:04 -08:00
Simon McVittie b66dba2a9d test: Don't accept results that are much less than expected
While looking at the other tests in this file, I noticed that instead
of checking for a result in the range of expected ± FLT_EPSILON as I
would have expected, these tests would accept any result strictly less
than expected + FLT_EPSILON, for example a wrong result that is very
large and negative. This is presumably not what was intended, so add
the SDL_fabs() that I assume was meant to be here.

Fixes: 474c8d00 "testautomation: don't do float equality tests"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-02 07:44:04 -08:00
Anonymous Maarten f1f9e27128 testautomation_math: do relative comparison + more precise correct trigonometric values
If the magnitude of the expected result is small, then we can safely
assume that the actual calculated result matches it to 10 decimal
places.

However, if the magnitude is very large, as it is for some of our exp()
tests, then 10 decimal places represents an unrealistically high level
of precision, for example 24 decimal digits for the test that is
expected to return approximately 6.6e14. IEEE 754 floating point only
has a precision of about 16 decimal digits, causing test failure on
x86 compilers that use an i387 80-bit extended-precision register for
the result and therefore get a slightly different answer.

To avoid this, scale the required precision with the magnitude of the
expected result, so that we accept a maximum error of either 10 decimal
places or 1 part in 1e10, whichever is greater.

[smcv: Added longer commit message explaining why we need this]
(cherry picked from commit 880c69392a)
2024-02-02 07:44:04 -08:00
Simon McVittie babca704e0 testautomation: Don't expect exp to yield exact floating point results
In the Steam Runtime 1 'scout' environment, when compiling for i386
using the default gcc-4.6, Exp(34.125) matches the desired value to the
precision shown in the log (6 decimal places) but is not an exact match
for the desired value.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-02 07:44:04 -08:00
Sam Lantinga d04fea8b87 Even more miscellaneous gamepad buttons! 2024-02-01 20:34:05 -08:00
Sam Lantinga cb70e972e3 Added miscellaneous gamepad buttons for additional macro buttons on some controllers 2024-02-01 20:15:01 -08:00
Sam Lantinga ea0853d23d Added an HDR gradient test to testcolorspace 2024-02-01 15:36:49 -08:00
Sam Lantinga 90597aeaef HDR10 colorspace isn't currently supported
You can't do blending directly in PQ space, which means you have to create a scene render target in linear space and use shaders to convert PQ texture data to linear, etc. All of this is out of scope for the SDL 2D renderer at the moment.
2024-02-01 12:17:35 -08:00
Sam Lantinga 496ed01bdb Detect blending in HDR10 colorspace 2024-02-01 12:17:35 -08:00
Sam Lantinga 6f443e2aca Added support for the scRGB colorspace on D3D11 and D3D12 2024-01-31 18:07:00 -08:00
Sam Lantinga c1f97c8e07 Fixed testgeometry after color format change (thanks @sezero!) 2024-01-30 23:31:48 -08:00
Sam Lantinga f257eb4481 Added the concept of colorspace to the SDL renderer
This allows color operations to happen in linear space between sRGB input and sRGB output. This is currently supported on the direct3d11, direct3d12 and opengl renderers.

This is a good resource on blending in linear space vs sRGB space:
https://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/

Also added testcolorspace to verify colorspace changes
2024-01-30 09:48:02 -08:00
Sam Lantinga 554f0625d3 Renderer colors now have floating point precision 2024-01-30 09:48:02 -08:00
Frank Praznik 344ec60f8f tests: Fix window centering test with Wayland display scaling mode
The usable fullscreen bounds need to be queried after window creation, as Wayland can send different usable bounds depending on the focused window's scaling mode.
2024-01-28 13:31:42 -05:00
Sam Lantinga 9f7eb6c4c1 Fixed testautomation log callback calling convention 2024-01-27 22:44:13 -08:00
Sam Lantinga 12bdb2b4d0 Added the environment variable SDL_LOGGING to control default log output 2024-01-27 19:30:22 -08:00
Sam Lantinga f66fe7e221 Replaced SDL_GetJoystickCaps() with joystick properties
Fixes https://github.com/libsdl-org/SDL/issues/8927
2024-01-27 15:11:52 -08:00
Sam Lantinga 3b55c7d1f4 Shortened SDL property names 2024-01-27 13:00:50 -08:00
Sam Lantinga 5ddd97062e Added test code to validate SDL_WaitEventTimeout()
You can enable this by defining TEST_WAITEVENTTIMEOUT
2024-01-25 06:29:15 -08:00
Ozkan Sezer 205c417f74 testgles2.c, testgles2_sdf.c: adjust for new SDL_PLATFORM_WINDOWS meaning. 2024-01-24 21:20:50 +03:00
Anonymous Maarten 31d133db40
Define SDL_PLATFORM_* macros instead of underscored ones (#8875) 2024-01-24 01:40:51 +00:00
Sam Lantinga cd231a65f6 Added SDL_GetJoystickCaps() and SDL_GetGamepadCaps() to get the capabilities of controllers
Also added SDL_GAMEPAD_CAP_PLAYER_LED to let the application know if the controller has a visible player LED
2024-01-22 19:23:42 -08:00
Sam Lantinga 8f20ef5b43 Re-enable C runtime with Mingw, and disable the problematic math test 2024-01-21 06:55:29 -08:00
Sam Lantinga 5e70ee29cc Build SDL with the static C runtime on Visual Studio 2024-01-21 06:55:29 -08:00
Sam Lantinga 8c7f5b73e8 Fixed build
The flip directions aren't 1 and -1, just use SDL_FLIP_NONE for now
2024-01-20 08:42:52 -08:00
Sam Lantinga 308906ba25 Added SDL_FlipSurface() to flip a surface vertically or horizontally
Fixes https://github.com/libsdl-org/SDL/issues/8857
2024-01-20 06:31:37 -08:00
Sam Lantinga 64972b4184 Fixed build 2024-01-19 17:21:05 -08:00
Sam Lantinga 6a00ae7e58 Fixed rendering diagonal lines within a viewport
The drawing uses the origin of the viewport as the coordinate origin, so we only need to clip against the size of the viewport.

Also added a unit test to catch this case in the future
2024-01-19 16:29:38 -08:00
Simon McVittie 81ac656b7c SDL_CalculateRGBSize, SDL_CalculateYUVSize: set the error indicator
These functions historically didn't set the error indicator on overflow.

Before commit 447b508a "error: SDL's allocators now call SDL_OutOfMemory
on error", their callers would call SDL_OutOfMemory() instead, which was
assumed to be close enough in meaning: "that's a silly amount of memory
that would overflow size_t" is similar to "that's more memory than
is available". Now that responsibility for calling SDL_OutOfMemory()
has been pushed down into SDL_calloc() and friends, the functions that
check for overflows might as well set more specific errors.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-18 13:21:50 -08:00
Simon McVittie e9a0edc847 testautomation_surface: Really make width * bpp overflow
A surface of width (0x7fff'ffff) / 2 = 0x3fff'ffff is not quite large
enough to make the pitch overflow in the way we wanted to test here:
with a 32-bit format, that makes each row 0xffff'fffc bytes, which
(just) fits in a 32-bit unsigned size_t. Increasing it to 0x4000'0000
pixels per row is enough to trigger the overflow we intended to test.

In SDL 2, this test bug was hidden by the fact that allocating
0xffff'fffc bytes on a 32-bit platform is very likely to fail, and SDL 2
reported both "malloc() failed" and "this amount of memory is too large
for a size_t" with the same error code.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-18 13:21:50 -08:00
Simon McVittie eb059538f8 testautomation_surface: Really make pitch + alignment overflow
Adding 3 bytes of alignment to 0x7fff'ffff is not enough to make it
overflow a 4-byte unsigned size_t, so this test was not exercising
the intended failure mode. We cannot actually make this overflow
with a signed 32-bit width and an 8-bit format: the maximum width is
not enough to achieve that. However, if we switch to a 24-bit format,
we can make the calculation overflow.

In SDL 2, this test bug was hidden by the fact that allocating
0x7fff'ffff bytes on a 32-bit platform will usually fail, and SDL 2
reported both "malloc() failed" and "this amount of memory is too large
for a size_t" with the same error code.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-18 13:21:50 -08:00
Ozkan Sezer 4fdc291f5d Add spaces around SDL_PRI??? to avoid potential compiler warnings. 2024-01-18 23:41:10 +03:00
Sam Lantinga a31dc6dfcb Switched SDL_TouchID and SDL_FingerID to be Uint64 with 0 being an invalid value 2024-01-18 10:55:24 -08:00
Sam Lantinga cda2bffeee Re-add SDL_HAPTIC_SQUARE for SDL 3.0
Fixes https://github.com/libsdl-org/SDL/issues/8753
Closes https://github.com/libsdl-org/SDL/pull/8831
Closes https://github.com/libsdl-org/SDL/pull/8783
2024-01-18 09:24:03 -08:00
Sam Lantinga fc0c774976 Renamed SDL_ThreadID() to SDL_GetCurrentThreadID()
Also renamed SDL_threadID to SDL_ThreadID and made it Uint64 for consistency with other ID types
2024-01-18 08:18:37 -08:00
Sam Lantinga d6a41f8f31 Updated SDL_TimerID to use the same type as other IDs in SDL 2024-01-18 07:08:15 -08:00
Sam Lantinga f8dfee01bb Made SDL_ReadSurfacePixel a public function
Fixes https://github.com/libsdl-org/SDL/issues/8320
2024-01-18 07:00:10 -08:00
Ozkan Sezer f7ba340999 remove several instances of unnecessary emptry str "" after SDL_PRI??? 2024-01-18 17:25:50 +03:00
Sam Lantinga c540c77756 Removed SDL_INIT_EVERYTHING
Fixes https://github.com/libsdl-org/SDL/issues/8709
2024-01-18 06:17:58 -08:00
Sam Lantinga a2665f54c8 Updated the atomic API for SDL 3.0 naming conventions
Fixes https://github.com/libsdl-org/SDL/issues/7388
2024-01-18 04:41:34 -08:00
Sam Lantinga f224af5ac5 Updated Haptic API for SDL 3.0 conventions
Also removed the XInput haptic support since using the haptic API for rumble is no longer supported.
2024-01-18 03:26:11 -08:00
Frank Praznik 4f3d4bd110 wayland: Add the ability to import and wrap external surfaces
Add the ability to import and wrap external surfaces from external toolkits such as Qt and GTK.

Wayland surfaces and windows are more intrinsically tied to the client library than other windowing systems, so it is necessary to provide a way to initialize SDL with an existing wl_display object, which needs to be set prior to video system initialization, or export the internal SDL wl_display object for use by external applications or toolkits. For this, the global property SDL_PROPERTY_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER is used.

A Wayland example was added to testnative, and a basic example of Qt 6 interoperation is provided in the Wayland readme to demonstrate the use of external windows with both SDL owning the wl_display, and an external toolkit owning it.
2024-01-15 13:54:35 -05:00
Sylvain 101f903bb1 testgeometry: allow to use arrows to move the triangle 2024-01-12 11:53:34 -08:00