Commit Graph

2025 Commits (5a21febecbec3e5f2d110d700fd4ffc58d6603e6)

Author SHA1 Message Date
Sam Lantinga b5057edf29 Remove unused SDL_TextureModulate enum
Fixes https://github.com/libsdl-org/SDL/issues/6387
2023-11-07 09:23:26 -08:00
Sam Lantinga 9458cbf75e Removed unused SDL_OSEvent 2023-11-07 09:14:35 -08:00
Frank Praznik 1a57f6bb29 wayland: Remove QtWayland extensions
These were added a very long time ago and seem to serve no purpose now, as the functionality they provided is now in core Wayland protocols, current information on their usage and status is nonexistent, no modern compositor seems to support them, and the code paths are untested and subject to bit-rot at this point. It also causes duplicate symbol issues when statically linking an application to both Qt and SDL.
2023-11-07 11:00:32 -05:00
SDL Wiki Bot fccec65afe Sync SDL3 wiki -> header 2023-11-06 18:32:15 +00:00
Ryan C. Gordon 2f92807087
vulkan: SDL_Vulkan_CreateSurface now accepts an app-provided allocator.
Fixes #3638.
2023-11-06 13:31:20 -05:00
Ryan C. Gordon c53843a961
docs: Remove Doxygen `\brief` tags.
Doxygen and the wiki bridge don't need them; they'll both just use the first
line/sentence instead.

Fixes #8446.
2023-11-06 10:26:06 -05:00
Ozkan Sezer c132295ad7 SDL_FlushEventMemory is not a public procedure. 2023-11-06 17:40:56 +03:00
Ryan C. Gordon 7ac281f800
Sync wiki -> headers. 2023-11-06 09:33:05 -05:00
Sam Lantinga f7d40b7594 Added 10-bit pixel formats in addition to SDL_PIXELFORMAT_ARGB2101010
Added SDL_PIXELFORMAT_XRGB2101010, SDL_PIXELFORMAT_XBGR2101010, SDL_PIXELFORMAT_ABGR2101010

Fixes https://github.com/libsdl-org/SDL/issues/3553
2023-11-06 00:41:09 -08:00
Sam Lantinga 04dfca958a Added a note to events indicating that memory is owned by SDL 2023-11-05 21:25:43 -08:00
Sam Lantinga 70c149c88f Automatically clean up memory associated with events 2023-11-05 09:14:11 -08:00
Sam Lantinga d3f2eb2aba Use XINPUT_STATE instead of XINPUT_STATE_EX (thanks Andrew!)
XINPUT_STATE_EX isn't actually a thing, we can just use the normal XINPUT_STATE

Fixes https://github.com/libsdl-org/SDL/issues/2797

(cherry picked from commit e8f4045d0bccacbf8f4b716d0dde17140e9f2cc4)
2023-11-04 22:28:09 -07:00
Sam Lantinga 75ea3a8d32 Dynamically allocate long text for SDL_EVENT_TEXT_INPUT events
This prevents input text from being split across Unicode combining or modifier characters, and in practice allocations will rarely happen.
2023-11-04 20:55:10 -07:00
Sam Lantinga 2a1660ab51 Additional cleanup for SDL_RWprintf() (thanks @sezero!) 2023-11-04 20:47:08 -07:00
Ryan C. Gordon e5f2cea234
Sync wiki -> headers 2023-11-04 22:18:38 -04:00
Sam Lantinga ad842dd5ad Fixed a typo in SDL_log.h 2023-11-04 16:46:08 -07:00
Sam Lantinga f9d11807c0 Added SDL_RWprintf() and SDL_RWvprintf() to do formatted printing to an SDL_rwops stream
Fixes https://github.com/libsdl-org/SDL/issues/2390
2023-11-04 16:46:08 -07:00
Sam Lantinga 91f0456391 Add the source application for drag and drop events (thanks Nathan!)
This is only implemented on iOS, but is useful for third party application integrations.

Fixes https://github.com/libsdl-org/SDL/issues/2024
2023-11-04 13:00:41 -07:00
Ryan C. Gordon 1a8bf31a69 include: Fixing whitespace on SDL_MixAudioFormat. 2023-11-04 15:06:41 -04:00
Sam Lantinga d07a264a9b Use the default UCS2/UCS4 conversion rather than non-portable INTERNAL encoding
Fxies https://github.com/libsdl-org/SDL/issues/1497
2023-11-04 12:01:30 -07:00
Sam Lantinga ad9dcdbbce Clarify that you should use the other field when reading the event 2023-11-04 09:58:35 -07:00
Ryan C. Gordon a19029e3c1
docs: Updated README-main-functions.md based on feedback. 2023-11-04 10:03:10 -04:00
Sam Lantinga 7e445da569 Added SDL_CleanupEvent()
This is used to free any dynamically allocated memory in events.
2023-11-04 06:47:24 -07:00
SDL Wiki Bot 3ab6670cb1 Sync SDL3 wiki -> header 2023-11-04 05:36:15 +00:00
Sam Lantinga f439ccfc1a Updated return values for SDL event functions
SDL_PollEvent(), SDL_WaitEvent(), and SDL_WaitEventTimeout() all return SDL_bool.
SDL_AddEventWatch() returns an int result code.

Also improved timeout accuracy in SDL_WaitEventTimeout()
2023-11-03 22:31:42 -07:00
Sam Lantinga a76d8e39aa Changed SDL_bool from an enum to unsigned int
Fixes https://github.com/libsdl-org/SDL/issues/7957
2023-11-03 09:54:04 -07:00
Ryan C. Gordon 70d75b4a23
Sync wiki -> headers 2023-11-03 10:13:46 -04:00
Ryan C. Gordon 07a776f255
include: Fixed documentation for SDL_Vulkan_GetInstanceExtensions. 2023-11-02 15:12:24 -04:00
ilyas-taouaou 9224a0a2d8 Fix emscripten, android, uikit and windows 2023-11-02 14:27:36 -04:00
ilyas-taouaou d0d8b28df1 Change SDL_Vulkan_GetInstanceExtensions 2023-11-02 14:27:36 -04:00
Ryan C. Gordon 9c664b0062
main: Added _optional_ callback entry points.
This lets apps optionally have a handful of callbacks for their entry points instead of a single main function. If used, the actual main/SDL_main/whatever entry point will be implemented in the single-header library SDL_main.h and the app will implement four separate functions:

First:

    int SDL_AppInit(int argc, char **argv);

This will be called once before anything else. argc/argv work like they always do. If this returns 0, the app runs. If it returns < 0, the app calls SDL_AppQuit and terminates with an exit code that reports an error to the platform. If it returns > 0, the app calls SDL_AppQuit and terminates with an exit code that reports success to the platform. This function should not go into an infinite mainloop; it should do any one-time startup it requires and then return.

Then:

     int SDL_AppIterate(void);

This is called over and over, possibly at the refresh rate of the display or some other metric that the platform dictates. This is where the heart of your app runs. It should return as quickly as reasonably possible, but it's not a "run one memcpy and that's all the time you have" sort of thing. The app should do any game updates, and render a frame of video. If it returns < 0, SDL will call SDL_AppQuit and terminate the process with an exit code that reports an error to the platform. If it returns > 0, the app calls SDL_AppQuit and terminates with an exit code that reports success to the platform. If it returns 0, then SDL_AppIterate will be called again at some regular frequency. The platform may choose to run this more or less (perhaps less in the background, etc), or it might just call this function in a loop as fast as possible. You do not check the event queue in this function (SDL_AppEvent exists for that).

Next:

    int SDL_AppEvent(const SDL_Event *event);

This will be called once for each event pushed into the SDL queue. This may be called from any thread, and possibly in parallel to SDL_AppIterate. The fields in event do not need to be free'd (as you would normally need to do for SDL_EVENT_DROP_FILE, etc), and your app should not call SDL_PollEvent, SDL_PumpEvent, etc, as SDL will manage this for you. Return values are the same as from SDL_AppIterate(), so you can terminate in response to SDL_EVENT_QUIT, etc.

Finally:

    void SDL_AppQuit(void);

This is called once before terminating the app--assuming the app isn't being forcibly killed or crashed--as a last chance to clean up. After this returns, SDL will call SDL_Quit so the app doesn't have to (but it's safe for the app to call it, too). Process termination proceeds as if the app returned normally from main(), so atexit handles will run, if your platform supports that.

The app does not implement SDL_main if using this. To turn this on, define SDL_MAIN_USE_CALLBACKS before including SDL_main.h. Defines like SDL_MAIN_HANDLED and SDL_MAIN_NOIMPL are also respected for callbacks, if the app wants to do some sort of magic main implementation thing.

In theory, on most platforms these can be implemented in the app itself, but this saves some #ifdefs in the app and lets everyone struggle less against some platforms, and might be more efficient in the long run, too.

On some platforms, it's possible this is the only reasonable way to go, but we haven't actually hit one that 100% requires it yet (but we will, if we want to write a RetroArch backend, for example).

Using the callback entry points works on every platform, because on platforms that don't require them, we can fake them with a simple loop in an internal implementation of the usual SDL_main.

The primary way we expect people to write SDL apps is with SDL_main, and this is not intended to replace it. If the app chooses to use this, it just removes some platform-specific details they might have to otherwise manage, and maybe removes a barrier to entry on some future platform.

Fixes #6785.
Reference PR #8247.
2023-11-01 18:40:41 -04:00
Anonymous Maarten 6127ac0871 Use SDL_DISABLE_ALLOCA instead of HAVE_ALLOCA in SDL_stdinc.h 2023-10-28 18:54:12 +02:00
SDL Wiki Bot 2e9eb1073d Sync SDL3 wiki -> header 2023-10-26 18:23:13 +00:00
Ryan C. Gordon e6116d399a
mutex: Removed SDL_MUTEX_MAXWAIT.
Fixes #8436.
2023-10-26 14:21:53 -04:00
SDL Wiki Bot 82f48be3ef Sync SDL3 wiki -> header 2023-10-26 12:58:14 +00:00
Ryan C. Gordon 899eb0d042 thread: Locking mutexes and rwlocks are now void functions.
Almost nothing checks these return values, and there's no reason a valid
lock should fail to operate. The cases where a lock isn't valid (it's a
bogus pointer, it was previously destroyed, a thread is unlocking a lock it
doesn't own, etc) are undefined behavior and always were, and should be
treated as an application bug.

Reference Issue #8096.
2023-10-26 08:57:34 -04:00
Ryan C. Gordon b16165a33f
rwlock: SDL_UnlockRWLock was incorrectly tagged with SDL_RELEASE_SHARED.
It needs to be SDL_RELEASE_GENERIC, because it releases both exclusive
(writer) and shared (reader) locks.

Without this fix, clang's `-Wthread-safety` tests generate incorrect warnings.

Reference Issue #8096.
2023-10-24 14:42:02 -04:00
Sam Lantinga c98a14fdeb Renamed display added/removed events for consistency with the rest of the API
Fixes https://github.com/libsdl-org/SDL/issues/8425
2023-10-23 09:14:54 -07:00
SDL Wiki Bot 594fda4120 Sync SDL3 wiki -> header 2023-10-19 17:13:15 +00:00
Sam Lantinga 0d7c5a2c56 Updated Android API documentation 2023-10-19 10:12:34 -07:00
SDL Wiki Bot 142366c837 Sync SDL3 wiki -> header 2023-10-19 14:03:06 +00:00
Sam Lantinga 1f8f82b379 Removed redundant thread-safety information 2023-10-18 22:19:50 -07:00
SDL Wiki Bot a6edc75fe7 Sync SDL3 wiki -> header 2023-10-19 05:18:12 +00:00
Sam Lantinga 3c8edeb79b Clarified SDL property thread-safety information 2023-10-18 22:17:02 -07:00
SDL Wiki Bot 4fa821cb3e Sync SDL3 wiki -> header 2023-10-19 05:14:13 +00:00
Sam Lantinga 1c70760c0b Added thread-safety information for the new SDL properties API 2023-10-18 22:13:33 -07:00
Sam Lantinga b45a0d9016 Updated the documentation for SDL_LoadWAV_RW() 2023-10-17 20:27:49 -07:00
Zhile Zhu 6ddd96a4d0 Fix some wrong gamepad/controller event enums 2023-10-16 08:35:54 -04:00
Ryan C. Gordon ac71831350
Sync wiki -> headers 2023-10-12 15:20:53 -04:00
Sam Lantinga 4368f70ff9 Added properties to various SDL objects
The following objects now have properties that can be user modified:
* SDL_AudioStream
* SDL_Gamepad
* SDL_Joystick
* SDL_RWops
* SDL_Renderer
* SDL_Sensor
* SDL_Surface
* SDL_Texture
* SDL_Window
2023-10-11 22:38:00 -07:00
Sam Lantinga 973c8b3273 Added SDL properties API
Fixes https://github.com/libsdl-org/SDL/issues/7799
2023-10-11 22:38:00 -07:00
Ryan C. Gordon 0fe95cfba3
Sync wiki -> header 2023-10-10 10:49:24 -04:00
Sam Lantinga 2bd478ae65 Added SDL_GetTextureDXGIResource() to get the DXGI resource associated with a render texture.
Also switched the D3D11 and D3D12 renderers to use real NV12 textures for NV12 data.

The combination of these two changes allows us to implement 0-copy video decode and playback for D3D11 in testffmpeg without any access to the renderer internals.
2023-10-10 03:32:46 -07:00
Simon McVittie d88bf687a8 surface: Document the in-memory layout of the pixels
I don't think we ever explicitly said this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-10 03:24:43 -07:00
Simon McVittie 3698630bbc pixels: Document the naming convention
Whenever I have to fix something endianness-related, I always get
confused about whether the byte-oriented format that guarantees to put
red in byte 0 is RGBA8888 or RGBA32. (The answer is that it's RGBA32.)

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-10 03:24:43 -07:00
Simon McVittie 0d68f45879 test: Extract SDLTest_ReadSurfacePixel
This is essentially the same as was added in d95d2d70, but with clearer
error handling. It's implemented in a private header file so that it
can be shared with SDL_shape, which also wants this functionality.

Resolves: https://github.com/libsdl-org/SDL/issues/8319
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-10 03:23:20 -07:00
Frank Praznik 2a1058713c Bump libdecor feature check to look for 0.2.0
The version of libdecor tagged with support for the suspended event and min/max getters is 0.2.0, so update the checks to reflect this.
2023-09-25 12:07:54 -04:00
Ryan C. Gordon a4541a255e
audio: SDL_GetAudioStreamQueued now returns bytes, not frames.
Reference #8266.
2023-09-20 14:15:47 -04:00
Ryan C. Gordon 703aefbce0
Sync SDL3 wiki -> header 2023-09-20 14:08:32 -04:00
Ryan C. Gordon 34b931f7eb audio: Added SDL_GetAudioStreamQueued 2023-09-20 10:15:03 -04:00
Ryan C. Gordon 23206b9e3f audio: Added SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED
This fires if an opened device changes formats (which it can on Windows,
if the user changes this in the system control panel, and WASAPI can
report), or if a default device migrates to new hardware and the format
doesn't match.

This will fire for all logical devices on a physical device (and if it's
a format change and not a default device change, it'll fire for the
physical device too, but that's honestly not that useful and might change).

Fixes #8267.
2023-09-20 10:12:10 -04:00
Ryan C. Gordon 31229fd47f
include: Added a note about SDL's iOS app delegate functions.
Fixes #8250.
2023-09-15 09:50:24 -04:00
Sam Lantinga 859dc14add Replaced SDL_GetGamepadBindForAxis() and SDL_GetGamepadBindForButton() with SDL_GetGamepadBindings() 2023-09-13 23:01:28 -07:00
Sam Lantinga 9e50048ab6 Revert "Removed SDL_GamepadBinding from the API"
This reverts commit eb0955ef89.
2023-09-13 22:42:47 -07:00
Sam Lantinga 9f17d1a9d8 Don't reference the same function in "see also" 2023-09-13 11:01:00 -07:00
Ozkan Sezer 86505ea630 fix SDL_AudioStreamCallback documentation 2023-09-13 18:35:30 +03:00
SDL Wiki Bot d885d5c310 Sync SDL3 wiki -> header 2023-09-13 15:04:13 +00:00
Ryan C. Gordon 2f43f7bc53
audio: Allow querying of device buffer size. 2023-09-13 11:03:17 -04:00
Ryan C. Gordon cf95721130
audio: Added a hint to let apps force device buffer size.
This is a hint because apps might (probably mistakenly) believe they need this
to migrate from SDL2, but most things don't need to specify this.
2023-09-13 10:42:08 -04:00
Ryan C. Gordon 8b26e95f91
audio: Change SDL_AudioStreamCallback
Now it offers the total requested bytes in addition to the amount
immediately needed (and immediately needed might be zero if the stream
already has enough queued to satisfy the request.
2023-09-13 10:11:23 -04:00
Sam Lantinga cd633b9a88 Renamed SDL_IsAudioDevicePaused() to SDL_AudioDevicePaused()
This aligns with the SDL3 convention of removing "Is" from self-explanatory function names

Also improved some documentation in SDL_audio.h
2023-09-12 12:11:09 -07:00
Ryan C. Gordon a6e52f9e48
Sync SDL3 wiki -> header 2023-09-12 14:27:21 -04:00
Ryan C. Gordon 3a992af446 audio: Added a postmix callback to logical devices.
You can see it in action in testaudio by mousing over a logical device; it
will show a visualizer for the current PCM (whatever is currently being
recorded on a capture device, or whatever is being mixed for output on
playback devices).

Fixes #8122.
2023-09-09 16:26:37 -04:00
Ryan C. Gordon 116b0ec977
include: minor tweak to audio API documentation 2023-09-07 10:45:45 -04:00
Ryan C. Gordon fb13770353
include: Replaced old Bugzilla URL. 2023-09-07 10:44:30 -04:00
Brick f2ca9a615b Added SDL_AUDIO_FRAMESIZE 2023-09-05 17:56:58 -07:00
Brick 53122593f8 Added SDL_AUDIO_BYTESIZE 2023-09-05 17:56:58 -07:00
SDL Wiki Bot 544351c98e Sync SDL3 wiki -> header 2023-09-05 21:19:16 +00:00
Sam Lantinga 2e7d2b94eb Clarify that SDL_BlitSurface() ignores the width and height in dstrect 2023-09-05 14:18:43 -07:00
Sam Lantinga 3a932141e4 Restore audio format binary compatibility with SDL 2.0 2023-09-04 10:16:53 -07:00
Sam Lantinga 233789b0d1 Audio types have the same naming convention as other SDL endian types, e.g. [S|U][BITS][LE|BE]
Native endian types have no LE/BE suffix
2023-09-04 09:48:44 -07:00
SDL Wiki Bot 36b5f3e35c Sync SDL3 wiki -> header 2023-09-04 14:47:15 +00:00
Brick 0e552761b7 Renamed AudioStreamSpeed to AudioStreamFrequencyRatio 2023-09-04 07:46:18 -07:00
Brick 5394a805f4 Improved testaudiostreamdynamicresample
Tweaked color palette
2023-09-01 14:38:45 -04:00
Brick e55844274d Added SDL_(Get|Set)AudioStreamSpeed 2023-09-01 14:38:45 -04:00
Jeremy Demeule 6ff31e10cf
metal: Add hint to select low power device instead of the default one (#8182)
On some system like MacBook Pro Intel with AMD card, asking for the default device will always return the AMD GPU.
This is not an issue for 99% of the case when the renderer context is here to provide the maximum performance level like for game.
However, for video application using GPU for 1 quad and 1 texture, using the discrete GPU for that lead to an important power consumption (4 to 8W), heat increase, and fan noise.
With this patch, I successfully amend ffplay to only use the integrated GPU (i.e. the Intel one), instead of the discrete GPU (i.e. the AMD one).
2023-08-31 01:23:45 -07:00
SDL Wiki Bot f84c87f204 Sync SDL3 wiki -> header 2023-08-31 03:26:13 +00:00
Sam Lantinga a5e7214795 Add SDL_WINDOW_NOT_FOCUSABLE flag to set that the window should not be able to gain key focus
- Also adds SDL_SetWindowFocusable() to set/clear flag on existing windows
2023-08-30 20:29:51 -07:00
Sam Lantinga 82db2b58f9 Renamed audio stream callback and moved the userdata parameter first
In general SDL API callbacks are called with the userdata paramter first, to mimic C++ method call convention
2023-08-27 14:43:21 -07:00
SDL Wiki Bot 5bdad5210f Sync SDL3 wiki -> header 2023-08-27 20:55:12 +00:00
Ryan C. Gordon 58c859f64d audio: Rename SDL_GetAudioStreamBinding to SDL_GetAudioStreamDevice. 2023-08-27 16:54:30 -04:00
Ryan C. Gordon efd2023a72 audio: Fixed documentation. 2023-08-27 16:54:30 -04:00
Ryan C. Gordon 1e775e0eef audio: Replace SDL_CreateAndBindAudioStream with SDL_OpenAudioDeviceStream.
This is meant to offer a simplified API for people that are either migrating
directly from SDL2 with minimal effort or just want to make noise without
any of the fancy new API features.

Users of this API can just deal with a single SDL_AudioStream as their only
object/handle into the audio subsystem.

They are still allowed to open multiple devices (or open the same device
multiple times), but cannot change stream bindings on logical devices opened
through this function.

Destroying the single audio stream will also close the logical device behind
the scenes.
2023-08-27 16:54:30 -04:00
Brick 82e481b520 Added --randmem test parameter 2023-08-27 13:08:15 -07:00
SDL Wiki Bot e30e5c77e6 Sync SDL3 wiki -> header 2023-08-25 14:42:25 +00:00
Ethan Lee c0cd8c8142 gdk: Add SDL_GDKGetDefaultUser, SDL_GetPrefPath implementation 2023-08-25 10:40:16 -04:00
Sam Lantinga 8924d0d927 Added missing function prototype for SDL_WriteS64BE() 2023-08-23 21:19:25 -07:00
Frank Praznik be8c42cfd7 Clarify that a window being 'hidden' means that it is unmapped/ordered out
SDL considers a hidden window to be unmapped and blocks or defers certain operations until the window is shown again, however, the X11 and Cocoa backends would set the hidden flag when the window was minimized, which blocked the functionality of SDL_RestoreWindow().

Specify that a window with the hidden flag set is unmapped and not visible on the desktop or in the dock/taskbar without a call to SDL_ShowWindow(), and don't set the hidden flag in the X11 and Cocoa backends when the window is in the minimized state, but still mapped to the desktop.
2023-08-14 13:20:24 -04:00
David CARLIER 723bcd0a8b SDL_TriggerBreakppoint for riscv arch (both 32/64) version.
`ebreak` acts like int3 for x86, giving control of running process to debuggers.
2023-08-13 11:36:49 -04:00
Anonymous Maarten b7889a7389 winrt: use windowsio in non-libc mode
CMake's SDL_build_config.h force disables HAVE_STDIO_H when buiding
winrt in non-libc mode.

Becase CreateFileEx is not available in UWP mode, use CreateFile2
instead.
2023-08-12 17:37:52 +02:00