17516 Commits

Author SHA1 Message Date
Sam Lantinga
c6c195ff88 Always use WaitForSingleObjectEx() as a fallback in SDL_SYS_DelayNS()
That logic isn't specific to the Visual Studio build environment. Also switched it to use CreateEvent(), which works back to Windows XP.
2024-10-11 21:18:31 -07:00
Sam Lantinga
c5904d8710 Improved implementation of SDL_DelayPrecise() (thanks @nightmareci!)
Fixes https://github.com/libsdl-org/SDL/issues/10592
2024-10-11 21:18:31 -07:00
Sam Lantinga
25251a9405 Fixed warning C4723: potential divide by 0 2024-10-11 19:31:22 -07:00
Daniel Gibson
33366b0a4e Fix SDL_MAIN_USE_CALLBACKS with Android, introduce SDL_MAIN_EXPORTED
My simplification of the conditions for including SDL_main_impl.h
had one problem: I forgot that SDL_main_impl.h must be included
even on Android when SDL_MAIN_USE_CALLBACKS is used, because then a
SDL_main() function that makes sure the callbacks get called is needed,
and that function is implemented in SDL_main_impl.h

But OTOH, even when SDL_MAIN_USE_CALLBACKS is used, SDL_main_impl.h
should not implement a standard `int main(...)` function on Android
(because there the SDL-using native code is compiled as a library and
 the entry point is in SDLActivity.java, which calls SDL_main()
 in said library).

So the check for platforms that don't have *any* native main function
but just SDL_main() called from the outside should be handled in
SDL_main_impl.h, so both the normal and the callback case can avoid
generating a standard main() in the same way.
To do this, SDL_MAIN_EXPORTED is defined for platforms like Android,
where the real entry point (main() function) is outside of the code
that uses SDL, so
- SDL_main() must be visibly exported with SDL_DECLSPEC, so the outside
  code can call it
- SDL_main_impl.h must not implement a "real" main() function

Another small change based on this is defining SDLMAIN_DECLSPEC
at a more general place.

If another platform like Android (where the entry point is somewhere
else entirely, possibly implemented in a different programming language)
turns up, defining SDL_MAIN_NEEDED (so the users main() is renamed
to SDL_main()) and SDL_MAIN_EXPORTED should be all that's needed on the
SDL_main.h side - and if not then at least the implementation is
cleaner and clearer now, IMHO.

fixes #11162
2024-10-11 18:54:29 -07:00
Andrei Rafael Brongel
86ef790a23 explicit cast to int in SDL_bits 2024-10-11 18:52:06 -07:00
Sam Lantinga
3cd7e22e8b Fixed converting full range YUV to RGB
Updated from https://kdashg.github.io/misc/colors/from-coeffs.html

I'm not sure where the other formulas came from, but they weren't mathematically correct and resulted in slightly incorrect colors.
2024-10-11 18:12:05 -07:00
Petar Popovic
3086b25c4e Set hint SDL_HINT_MAC_SCROLL_MOMENTUM version to SDL 3.1.4. 2024-10-11 17:33:52 -07:00
SDL Wiki Bot
b676413657 Sync SDL3 wiki -> header
[ci skip]
2024-10-11 20:51:42 +00:00
expikr
48ff3efdb9
Clarify README-highdpi.md (#10083) 2024-10-11 13:50:37 -07:00
SDL Wiki Bot
e31c68427a Sync SDL3 wiki -> header
[ci skip]
2024-10-10 23:35:37 +00:00
Evan Hemsley
6ea4a66451
GPU: Add SDL_CalculateGPUTextureFormatSize (#11146)
---------

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
2024-10-10 16:34:38 -07:00
Petar Popovic
6d85127560 Rename hint string literal SDL_HINT_MAC_SCROLL_MOMENTUM 2024-10-10 16:16:36 -07:00
Caleb Cornett
3db10a6b2c
GPU: ASTC block size fixes (#11157) 2024-10-10 15:40:21 -07:00
Ryan C. Gordon
90a3a2359b thread: Rewrote generic Condition Variables.
This replaces the internal mutex with a semaphore, so we're only using a
single synchronization primitive to implement this, and cleans up some logic
around wait timeouts.

This now matches the logic of the originally cited work, from BeOS.

Fixes #3639.

(I think.)
2024-10-10 15:03:53 -04:00
Ozkan Sezer
41dfe2c246 test/testautomation_stdlib.c: fix gcc warning on 32 bit
test/testautomation_stdlib.c:361: warning: integer constant is too large for 'long' type
2024-10-10 21:10:24 +03:00
Sam Lantinga
73b995fbad Don't assume OpenGL on Android
This prevents Vulkan from initializing by default.

Fixes https://github.com/libsdl-org/SDL/issues/10279
2024-10-10 10:53:31 -07:00
SDL Wiki Bot
8aaaeb7560 Sync SDL3 wiki -> header
[ci skip]
2024-10-10 17:02:43 +00:00
SDL Wiki Bot
2a9cb68b91 Sync SDL3 wiki -> header
[ci skip]
2024-10-10 16:43:29 +00:00
Ryan C. Gordon
0babb284dd
fnsince.pl: Make fixes now that we've reached ABI lock.
Turns out history is messy, thank god for Perl.  :)

Fixes #11156.
2024-10-10 12:41:46 -04:00
Frank Praznik
40ff6a2785 test: Fix mouse focus test on X11
X11 seems to need a slight delay before warping the pointer to ensure that the window is actually fully visible on the desktop, or the pointer enter event may not be sent.

This also disables the warp focus test on XWayland, as warping the mouse cursor when outside the window on any Wayland desktop usually just doesn't work.
2024-10-10 11:37:45 -04:00
SDL Wiki Bot
e4b1a9f382 Sync SDL3 wiki -> header
[ci skip]
2024-10-10 15:24:38 +00:00
Ozkan Sezer
7ff819141d libm/e_exp.c: fix gcc warning on 32 bit:
src/libm/e_exp.c:105: warning: integer constant is too large for 'long' type
2024-10-10 18:23:20 +03:00
SDL Wiki Bot
ac6b9e2d19 Sync SDL3 wiki -> header
[ci skip]
2024-10-10 15:06:56 +00:00
Sam Lantinga
8262072d91 Fixed possible memset(NULL) call in testautomation's SDL_aligned_alloc() check
Fixes https://github.com/libsdl-org/SDL/issues/11144
2024-10-10 08:06:18 -07:00
Sam Lantinga
4b7c5f561b Fixed warning: ‘new_item.probe_len’ may be used uninitialized in this function 2024-10-10 08:06:18 -07:00
Sam Lantinga
c8f5f6d47a Added SDL_DelayPrecise()
SDL_DelayNS() now passes through to the high precision OS delay function, and SDL_DelayPrecise() tries to busy wait to get as close as possible to the desired wait time.

Fixes https://github.com/libsdl-org/SDL/issues/11141
2024-10-10 08:06:18 -07:00
Sam Lantinga
28a70a5b71 Use the correct version for the \since field 2024-10-10 08:06:18 -07:00
Anthony
bf351b0b0e
Add more configChanges to Android Manifest (#11145)
The addition of layoutDirection is required to prevent the forced restart due to a locale change. Also adding grammaticalGender, fontWeightAdjustment & fontScale for good measure.
2024-10-10 07:53:34 -07:00
David Gow
9c322386bf gpu: vulkan: Fix an uninitialised structure in SDL_BlitGPUTexture()
The SDL_GPUColorTargetInfo structure needs to be zeroed, as otherwise we
can end up trying to create a resolve_texture which doesn't exist,
causing a rather difficult-to-debug segfault when calling
SDL_BlitGPUTexture() with a load op of SDL_GPU_LOADOP_CLEAR.
2024-10-10 07:16:02 -07:00
Evan Hemsley
da5a1585cd
GPU: Avoid calling SDL_GetWindowSizeInPixels when possible (#11139) 2024-10-09 18:59:07 -07:00
SDL Wiki Bot
4707bb730e Sync SDL3 wiki -> header
[ci skip]
2024-10-10 00:32:39 +00:00
Sam Lantinga
9023a199dd Fixed crash in RLE colorkey blitting
Fixes Maelstrom running over sdl2-compat with SDL3
2024-10-09 12:11:21 -07:00
Sam Lantinga
f946f87f30 Don't rely on event.buttonMask being set in touchesEnded
Fixes https://github.com/libsdl-org/SDL/issues/11131
2024-10-09 11:35:39 -07:00
Sam Lantinga
ee9b6204cf Updated to version 3.1.5 for development
We should bump the version immediately before and after release so the release version corresponds to a fixed snapshot of code.
2024-10-09 11:02:01 -07:00
SDL Wiki Bot
02f3a96476 Sync SDL3 wiki -> header
[ci skip]
2024-10-09 16:49:57 +00:00
Sam Lantinga
f8eac30276 Added SDL_StepBackUTF8() 2024-10-09 09:49:10 -07:00
Sam Lantinga
1f08a03794 Switched drag-n-drop logging to trace level
The logging is extremely verbose and covers the entire data exchange process, which is more suited to the trace level.
2024-10-09 07:35:21 -07:00
Daniel Ludwig
5b6342a00d Default SDL_HINT_JOYSTICK_GAMEINPUT to "1" on GDK platforms 2024-10-09 07:30:13 -07:00
Daniel Ludwig
ed87e7e434 test: enable GameInput driver on GDK platforms
By default, it's the only driver available on Xbox, but disabled.
2024-10-09 07:30:13 -07:00
Daniel Ludwig
acb18e05b5 GPU: fix swapchain buffer size not set on Xbox 2024-10-09 07:30:13 -07:00
Sam Lantinga
ff834f7733 Removed the restrict keyword
It doesn't compile with older Visual Studio and I verified on godbolt.org that the way it was used here doesn't impact code generation at all.
2024-10-08 20:48:13 -07:00
Delta
8e6ead2f7b
[GPU] Added ASTC texture format support (#11116) 2024-10-08 18:45:04 -04:00
Ryan C. Gordon
02434cd293
emscripten: Fixes for data addresses above 2gb
This includes both wasm64 and wasm32 when addressing more than 2gb of memory.

Fixes: #9052

(Manually cherry-picked from 3deb07ea395373204462130c1e062bc1f71fe060.)
2024-10-08 17:41:18 -04:00
Sam Lantinga
c34790f9f1 Fixed spacing 2024-10-08 11:49:08 -07:00
Daniel Gibson
312ecc4a52 SDL_main.h: Remove dead code for hypothetical C++ platforms
If WinRT returns after all, or a similarly bad platforms turns up,
the code can still be found in the git history.
But keep in mind that it then will have to be added *before* the
 #if ( defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_NEEDED) ...
case for platforms that support plain C to work correctly
2024-10-08 11:47:33 -07:00
Daniel Gibson
823b218051 Simplify code to include SDL_main_impl.h in SDL_main.h
Basically all platforms where SDL_main.h renames main() to SDL_main()
use the platform-specific main() (or WinMain() or whatever)
implementations in SDL_main_impl.h - and that renaming is enabled with:
  #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) \
      || defined(SDL_MAIN_USE_CALLBACKS)
    #define main SDL_main
  #endif

The only exception is Android, where main() *is* renamed, but
SDL_main_impl.h isn't used, because SDL_main() is called from Java.

So I think it's cleaner and less error-prone (for adding additional
platforms that need SDL_main() in the future), to use the same check
for including SDL_main_impl.h as is used for `#define main SDL_main`
and only list the exceptions (currently Android) there explicitly.

If new platforms like Android turn up, they can easily be added there
by inserting "|| defined(SDL_PLATFORM_WEIRDPLATFORM)" right next
to the Android check.

See also https://github.com/libsdl-org/SDL/issues/11068#issuecomment-2399907535
2024-10-08 11:47:33 -07:00
Ryan C. Gordon
cba77834f2
init: Log '<unspecified>' not '(null)' if the app name isn't set.
Reference PR #11103.
2024-10-08 14:30:55 -04:00
Simon McVittie
fb8244d6d9 init: Also log the SDL revision here
This includes the version number, unless the developer is doing
something strange with git tags.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-10-08 14:29:02 -04:00
Simon McVittie
c24f7d2453 Log app ID as SYSTEM/INFO during initialization
This is not shown by default, but will be shown when using
SDL_LOGGING=system=info or higher, where it will hopefully nudge app
authors towards initializing this information.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-10-08 14:29:02 -04:00
Sam Lantinga
e7ee92e822 Switched drag-n-drop logging to trace level
The logging is extremely verbose and covers the entire data exchange process, which is more suited to the trace level.
2024-10-08 10:56:27 -07:00