Compare commits

...

88 commits

Author SHA1 Message Date
Ozkan Sezer d18b2e4129 typo fix to config.sub,
from https://lists.gnu.org/archive/html/config-patches/2023-01/msg00001.html
2023-01-21 10:15:02 +03:00
Ozkan Sezer bd5c355a34 SDL_thread.h: fix SDL_CreateThreadWithStackSize macro for OS/2
(cherry-picked from commit 738442b82a)
2022-12-27 00:15:20 +03:00
Ozkan Sezer facc408097 SDL_thread.h: fix beginthread param of SDL_CreateThreadWithStackSize for win32
(cherry-picked from commit 29ba5f5d64)
2022-12-27 00:15:20 +03:00
Vincent Hamm c7d5642e43 Fix SDL_CreateThreadWithStackSize not passing staacksize with win32 static api 2022-12-27 00:15:20 +03:00
Anonymous Maarten b42c033b13 cmake: use target_link_libraries to pass -Wl,--undefined=WinMain
(cherry-picked from commit e2060de714)
2022-11-29 21:15:22 +03:00
Frank Praznik d41985cfbc wayland: Fix libdecor_dispatch signature
The function returns an int, not a bool.
(cherry picked from commit f47169fcba)
2022-11-24 17:27:40 +03:00
Ozkan Sezer c1307133ce SDL_UDEV_DelCallback: return early if _this is NULL
Fixes https://github.com/libsdl-org/SDL/issues/6548
(cherry picked from commit 6dc96aa745)
2022-11-18 18:02:40 +03:00
Sylvain 4d605ae002 Fix usage of sizeof() in test/testgles*.c files
(cherry-picked from commit 71f2864b3a)
2022-11-17 17:29:28 +03:00
Sylvain 3a885f888a
Fixed bug #6537 - AIX: use PAUDIO_WaitDevice 2022-11-17 11:57:07 +01:00
Ozkan Sezer 6539b70062 SDL_pixels.c (SDL_MasksToPixelFormatEnum): add missing break to switch.
Hand-picked from commit ec58a817ef
2022-11-16 20:55:04 +03:00
Ozkan Sezer 8b696541ed CI, MSVC: update to use microsoft/setup-msbuild v1.1.3.
Fixes github deprecation warnings
2022-11-16 00:56:04 +03:00
Anonymous Maarten 711d30ddd4 The SDL2::SDL2 target in SDL2.framework needs to see the SDL2 include folder
SDL.h includes other files through SDL2/SDL_xxx.h
2022-11-15 19:33:43 +01:00
Ryan C. Gordon c93900437f audio: Avoid accumulation errors in resampler.
Fixes #6391.
(cherry picked from commit 78f97108f9)
2022-11-05 20:01:00 +03:00
Sam Lantinga 55b03c7493 Updated to version 2.24.2 for point release 2022-11-01 05:47:12 -07:00
Anonymous Maarten beeac60227 cmake: fix finding wayland-libdecor
It was broken in 11d53c84a7
(cherry-picked from commit 0823b5973a)
2022-10-24 20:37:00 +03:00
Anonymous Maarten 214258660f cmake: use pkg-config's library dirs as hint for finding a shared library
(cherry-picked from commit 11d53c84a7)
2022-10-24 20:37:00 +03:00
Sam Lantinga 08f83f953c Don't use RAWINPUT joystick driver on Windows XP
Fixes https://github.com/libsdl-org/SDL/issues/6400
(cherry-picked from commit 5025f24033)
2022-10-24 20:37:00 +03:00
Sam Lantinga d1dcbfe9e9 Only check to see if the ICC profile changes when the display changes or we gain focus
Fixes https://github.com/libsdl-org/SDL/issues/6366
(cherry-picked from commit 61b5360e17)
2022-10-24 20:37:00 +03:00
Sam Lantinga c0d1f73247 d3d12: actually execute the pending commands before processing resize
This makes sure all the resources are in the expected state

Fix the D3D12 case in https://github.com/libsdl-org/SDL/issues/6376
(cherry-picked from commit df1bd07dee)
2022-10-24 20:37:00 +03:00
Sam Lantinga 923ab93969 d3d12: fixed window resize handling
Fixes https://github.com/libsdl-org/SDL/issues/6355
(cherry-picked from commit f99fc3268e)
2022-10-24 20:37:00 +03:00
Sam Lantinga 1f82b4a96f d3d12: reset the vertex buffer size when it is released
(cherry-picked from commit 490c20f93f)
2022-10-24 20:37:00 +03:00
GNQG a053211a2a fix SDL_SendEditingText when long composition text is enabled and strlen(text) == SDL_TEXTEDITINGEVENT_TEXT_SIZE
(cherry-picked from commit 965ba1e097)
2022-10-24 20:15:00 +03:00
Sam Lantinga 2d580f8f45 Define _USE_MATH_DEFINES for Visual Studio (thanks @pionere!)
Fixes https://github.com/libsdl-org/SDL/issues/3790
(cherry-picked from commit c6e8961979)
2022-10-24 20:04:21 +03:00
Anonymous Maarten b8c6d3d7e1 cmake: mark hidapi as disabled when not found
(cherry-picked from commit 19b13aab98)
(cherry-picked from commit c3495ec6ea)
(cherry-picked from commit 6dfd7a17e1)
2022-10-24 20:04:21 +03:00
Anonymous Maarten 1e5daf1bef cmake: fix build with SDL_WAYLAND_SHARED=OFF
(cherry-picked from commit 711846c1f4)
2022-10-24 20:04:21 +03:00
Simon McVittie 21e23ef913 testevdev: Explain why the test data is encoded the way it is
Signed-off-by: Simon McVittie <smcv@collabora.com>

(cherry-picked from commit 7d230af51d)
2022-10-24 20:04:21 +03:00
Simon McVittie 4a0ad650d0 testevdev: Add a static assertion for supported sizeof(long)
If this assertion fails on some platform (unlikely), we will need a
third implementation for SwapLongLE().

Signed-off-by: Simon McVittie <smcv@collabora.com>

(cherry-picked from commit 81dee31949)
2022-10-24 20:04:21 +03:00
Helge Deller e07f106760 testevdev: Fix detection of word size
The check for whether to use a 32- or 64-bit swap for an array of long
values always took the 64-bit path, because <limits.h> wasn't included
and therefore ULONG_MAX wasn't defined. Turn this into a runtime check,
which a reasonable compiler will optimize into a constant.

This fixes testevdev failures on 32-bit big-endian platforms such as hppa
and older powerpc. Little-endian and/or 64-bit platforms are unaffected.

[smcv: Added commit message]
Bug-Debian: https://bugs.debian.org/1021310
Co-authored-by: Simon McVittie <smcv@collabora.com>

(cherry-picked from commit fb32effd15)
2022-10-24 20:04:20 +03:00
Sam Lantinga 88e64108f5 Clarified that GNU sort isn't required, we just need the -V option to be supported
(cherry-picked from commit f687cbd4c6)
2022-10-24 20:04:20 +03:00
Sam Lantinga 1b5bf2ac65 GNU sort isn't available on older macOS and some BSD systems
Don't prevent building entirely, just warn that we won't be able to find dynamic libraries in this case.

Fixes https://github.com/libsdl-org/SDL/pull/6338
(cherry-picked from commit 8c587636dc)
2022-10-24 20:04:20 +03:00
Ozkan Sezer 679d33ab44 updated VS project file
(cherry-picked from commit e3b2830f99)
2022-10-24 20:04:20 +03:00
Ozkan Sezer 9e72ec4ed9 Makefile.w32: no need for the description field, we have a *.res already
(cherry-picked from commit 1b52145bad)
2022-10-24 20:04:20 +03:00
Ozkan Sezer 8104992064 testhaptic: fix watcom "&array may not produce intended result" warning
(cherry-picked from commit d022039529)
2022-10-24 20:04:20 +03:00
Ozkan Sezer 51958da000 loadso, dlsym, SDL_LoadFunction: cleanup the underscored name path.
- strlcpy was passed a wrong buffer length parameter. has worked so
  far by luck.
- use memcpy instead of strlcpy for simplicity.
- 'append' has been a typo: should be 'prepend'.

(cherry-picked from commit 3d415bc5d6)
2022-10-22 20:04:20 +03:00
Ozkan Sezer b435252b29 hidapi, libusb: remove os/2 symbol load hack after os/2 loadso updates
(cherry-picked from commit 65a38a4015)
2022-10-22 20:04:20 +03:00
Ozkan Sezer eb43d57880 os2 loadso improvements:
- SDL_LoadObject: upon failure, strip the .dll extension and retry,
  but only if module name has no path.
- SDL_LoadFunction: upon failure, retry with an underscore prepended,
  e.g. for gcc-built dlls.

(cherry-picked from commit 3f1b5efcca)
2022-10-22 20:04:20 +03:00
Ozkan Sezer 92937ff5e0 os2: fix error message for SDL_LoadObject()
(cherry-picked from commit 4264c0b674)
2022-10-22 20:04:20 +03:00
Anonymous Maarten 36b987dabe cmake: else() does not need an argument 2022-10-20 13:30:37 +02:00
Ryan C. Gordon 266ca2c933 coreaudio: Dispose of AudioQueue before waiting on the thread.
Otherwise the thread might block for a long time (more than 10 seconds!).
It's not clear to me why this happens, or why its safe to do this with a
resource that's still in use, but we have, until recently, always
disposed of the AudioQueue first, so changing back is probably okay.

Also changed the disposal to allow in-flight buffers to reach hardware;
otherwise you lose the last little bit of audio that's already been queued
but not played, which you can hear clearly in the loopwave test program.

Fixes #6377.
(cherry picked from commit e7ab581d79)
2022-10-19 20:29:24 +03:00
Ethan Lee b7e8e6f3b8 wayland: Check for the input handle before checking the keyboard handle
(cherry picked from commit be2cb00066)
2022-10-11 08:31:49 -07:00
Sam Lantinga 30579c8cd7 Don't try to create a semaphore for the mutex implementation if threads are disabled
Fixes https://github.com/libsdl-org/SDL/issues/6344

(cherry picked from commit 17b43b0fdd)
2022-10-10 14:35:30 -07:00
Ozkan Sezer 4726270ead WIN_GetDrawableSize: avoid NULL pointer dereference
Fixes https://github.com/libsdl-org/SDL/issues/6356
2022-10-08 23:01:28 +03:00
Sam Lantinga a1d1946dcb Use DWARF 4 debug information when building using mingw
See this bug for more information:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101377

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

(cherry picked from commit f18fae4c68)
2022-10-04 16:48:08 -07:00
Sam Lantinga 36524373db Updated version to 2.24.1 for point release
Also merged some updates to test-versioning.sh from main to correctly verify the version
2022-10-04 14:06:15 -07:00
Sam Lantinga 77f3a9cbe8 Only advertise the SDL_PIXELFORMAT_EXTERNAL_OES format if we can build the shader for it
(cherry picked from commit 5bc85d6788)
2022-10-04 12:33:16 -07:00
Sam Lantinga b8dacc37b5 Pretty print shaders for debugging purposes
(cherry picked from commit 2970710b5d)
2022-10-04 12:33:16 -07:00
Sam Lantinga a49a25671d Fixed OpenGL ES shader compilation on Linux
(cherry picked from commit bc57d3e35c)
2022-10-04 12:33:16 -07:00
Sam Lantinga 284cf11778 Fixed uninitialized variable warning
(cherry picked from commit 8a15a738f3)
2022-10-04 12:33:16 -07:00
Sam Lantinga 949addc94e Fixed OpenGLES shaders failing after renderer has been created
Cache all the shaders up front, so we can verify that they won't silently fail at runtime.

If compiling the fragment shaders with the precision hint fails, try again without specifying precision.

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

(cherry picked from commit b5102a551b)
2022-10-04 12:33:16 -07:00
Amir 23a4b9bdd6 android: fix some compiler warnings
(cherry picked from commit 7f415ce587)
2022-10-04 12:32:10 -07:00
Sam Lantinga ce29ebc3b8 Add GLES2 shader prologue infrastructure. (by @eloj)
There is supposedly an OpenGL ES2 target that does not support precision specifiers. However, the existing logic to detect this is currently broken in two ways:

1) There's a typo of the `#ifdef` as `#if`.
2) Checking for `GL_FRAGMENT_PRECISION_HIGH` can not be the correct way to detect this platform. Other targets, including some desktops, will also not have this defined (for various reasons).

Because some of the shader code is missing precision specifiers, and because a default is ONLY provided if `GL_FRAGMENT_PRECISION_HIGH` is set, these other targets break.

Instead of 'hard-coding' the prologue string into shaders in the C source, use our ability to provide a list of strings to `glShaderSource` instead, leaving the determination to run-time.

This commit closes https://github.com/libsdl-org/SDL/pull/6182

(cherry picked from commit 29f4a5ba0e)
2022-10-04 12:29:27 -07:00
Ryan C. Gordon 0733ef7e3f
build: Fixed some references to renamed test-versioning.sh
(cherry picked from commit f648c000bd)
2022-10-04 15:22:41 -04:00
Ryan C. Gordon d1b2f1ebb5
Moved test/versioning.sh to build-scripts/test-versioning.sh
Reference Issue #6171.

(cherry picked from commit d843d61cc1)
2022-10-04 15:22:33 -04:00
Ryan C. Gordon 15496201c9
build-scripts: Added update-version.sh
Fixes #6171.

(cherry picked from commit 8e14647759)
2022-10-04 15:22:08 -04:00
Anonymous Maarten a23b54b74a cmake+xcode: only create SDL2::SDL2main target when it does not exist again 2022-10-04 21:17:29 +02:00
Ryan C. Gordon b0a2164b2c coreaudio: Possibly fixed another shutdown race condition.
Reference Issue #6159.
(cherry picked from commit e6640ef2d4)
2022-10-02 12:22:20 +03:00
Ozkan Sezer 14bf8237c1 hidapi, libusb: backport read_thread indefinite loop fix from mainstream
Mainstream commit:
5ce9051e2f
(cherry picked from commit 8bcbdc706c)
2022-09-28 18:35:24 +03:00
Ryan C. Gordon cedd8e1138 coreaudio: Remove redundant variable.
(cherry picked from commit f6565c329b)
2022-09-28 17:05:50 +03:00
Ryan C. Gordon d6e939ddb5 coreaudio: Don't crash on shutdown in a race condition.
Fixed #6159.
(cherry picked from commit 411582c710)
2022-09-28 17:01:50 +03:00
Ryan C. Gordon 128c34b839 cocoa: Fix new windows setting SDL_WINDOW_BORDERLESS flag incorrectly.
Fixes #6172.
(cherry picked from commit 57b20e7b9e)
2022-09-27 21:33:40 +03:00
Anonymous Maarten a1026d6368 cmake: use check_symbol_exists to check dlopen + need for dl library
(cherry-picked from commit bfecd78159)
2022-09-27 17:01:01 +03:00
Ozkan Sezer d8b2a165af autotools: revised and silenced esound detection a bit.
(cherry-picked from commit 6b75a592a4)
2022-09-27 17:01:01 +03:00
Simon McVittie 4657d8be0d autotools: Require GNU sort
find_lib() uses sort -V, which is a GNU extension. Users of non-GNU
operating systems should either install GNU coreutils (assumed to
provide a gsort executable), or use the CMake build system.

Resolves: https://github.com/libsdl-org/SDL/issues/6106
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry-picked from commit 732e1530e3)
2022-09-27 17:01:01 +03:00
Anonymous Maarten c7950bf0c6 cmake: only add -Wl,--undefined=WinMain when building an executable
(cherry-picked from commit 653e433c08)
2022-09-27 14:37:55 +03:00
Sylvain 0f2503cf8a Fixed bug #6287 - SDL_FillRect failed for SDL_Surface with BitsPerPixel == 4
(cherry-picked from commit d71df6448b)
2022-09-27 14:22:32 +03:00
Ozkan Sezer 6ba5f08e5d add missing quotes to the fallback CHECK_OBJC_SOURCE_COMPILES macro
Closes:  https://github.com/libsdl-org/SDL/issues/6268 .
(cherry picked from commit 098a7a043e)
2022-09-21 10:37:40 +03:00
Ozkan Sezer 7bf4ca60f6 autotools: stop using AC_FUNC_MEMCMP and AC_FUNC_STRTOD
Closes:  https://github.com/libsdl-org/SDL/issues/6266 .
(cherry picked from commit db225dec41)
2022-09-20 21:39:10 +03:00
Anonymous Maarten 4d78a6fad4 cmake: only add -Wl,--undefined=WinMain when building an executable
(cherry picked from commit 3b20e0ecef)
2022-09-19 05:02:04 +03:00
Cameron Cawley 59e04dcc0b Fix SDL_PIXELFORMAT_INDEX1LSB test case 2022-09-18 01:29:56 +03:00
Cameron Cawley fa239a2192 Fix incorrect return value in X11_GetPixelFormatFromVisualInfo 2022-09-18 01:29:56 +03:00
Ozkan Sezer 45362dfe31 SDL_windows.h: guard WIN32_LEAN_AND_MEAN and STRICT macro defines.
also define them as 1, instead of empty.
Reference issue: https://github.com/libsdl-org/SDL/issues/6239
(cherry picked from commit 339f7a2f6b)
2022-09-17 17:40:10 +03:00
Ozkan Sezer 0df4d123db SDL_offscreenwindow.c: swap include order of SDL_egl_c.h/SDL_sysvideo.h
Fixes redefinition warnings from windows builds.
Reference issue: https://github.com/libsdl-org/SDL/issues/6239
(cherry picked from commit d86cb8ec9e)
2022-09-17 17:40:07 +03:00
Sam Lantinga ffcf32b4ff Fixed building with libusb not dynamicaly loaded
(cherry-picked from commit 3f89d1704d)
(cherry-picked from commit 4ebf34857a)
(cherry-picked from commit 5767dc710e)
(cherry-picked from commit 9d77945d36)
(cherry-picked from commit 2847696338)
2022-09-12 23:55:56 +03:00
Sam Lantinga 531ddf5eb5 Fixed macOS framework detection in sdl2.m4
Fixes https://github.com/libsdl-org/SDL/issues/6141
(cherry picked from commit 3d516b841a)
2022-09-12 23:28:28 +03:00
Sam Lantinga abac672a2d Fixed crash if there are no devices available
(cherry picked from commit 679582e702)
2022-09-12 21:33:50 +03:00
Ozkan Sezer 782862b95c apply commit d0a3570300 to cmake side too.
(cherry-picked from commit 5b2884cb02)
2022-09-12 20:37:56 +03:00
Ozkan Sezer 525e201728 regenerated configure script.
(cherry-picked from commit d936499670)
2022-09-12 20:37:56 +03:00
Sam James 0680314c2a configure.ac: fix configure tests broken with Clang 15 (implicit function declarations)
Clang 15 makes implicit function declarations fatal by default which
leads to some configure tests silently failing/returning
the wrong result.

Signed-off-by: Sam James <sam@gentoo.org>
(cherry-picked from commit d0a3570300)
2022-09-12 20:37:56 +03:00
Ozkan Sezer 7be77f0b3d Fix https://github.com/libsdl-org/SDL/issues/6191
(cherry picked from commit 5ffede35d9)
2022-09-06 19:56:55 +03:00
Cameron Cawley e70db38d60 Fix compatibility with Windows XP
(cherry picked from commit 10e1ef00e2)
2022-09-06 17:10:00 +03:00
Anonymous Maarten 08e8824372 cmake: fix location of SDL2::SDL2test imported library 2022-09-05 21:54:48 +02:00
Gleb Mazovetskiy b6661c016b CMake: Make SDL_SHARED/STATIC/TEST options
This makes it easier to set these options when SDL is used as a subprojects.
Since CMake v3.13+, one can simply `set(SDL_TEST OFF)` before include the SDL2 subproject because options do not override existing variables. (https://cmake.org/cmake/help/latest/policy/CMP0077.html#policy:CMP0077)
This is also true for `set(CACHE)` commands but only in CMake v3.21+ (https://cmake.org/cmake/help/latest/policy/CMP0126.html).
2022-09-04 13:59:43 +02:00
Anonymous Maarten 62302d08f1 cmake: always create SDL2::SDL2main target in autotools' cmake config script 2022-08-24 06:41:20 -07:00
Anonymous Maarten b19e2f1e56 cmake: create SDL2::SDL2main target in Apple framework official release 2022-08-24 06:41:20 -07:00
Oleg Derevenetz ac44b22a24 Use __ARM_ARCH instead of __ARM_ARCH__ 2022-08-22 18:22:03 -07:00
slime 84004d1e47 cocoa: change Shape data to use ObjC objects instead of C structs.
Fixes #6089
2022-08-21 15:36:34 -07:00
Anonymous Maarten 329794daf3 cmake: add library directories & pthread to imported targets of sdl2-config.cmake
This fixes linking to SDL2::SDL2-static on systems where external libraries such as X11 are not in a standard location.
Pthread also needs special care.
2022-08-20 19:17:37 -07:00
Sam Lantinga 3739dda6bd Fixed minimized window detection when handling WM_WINDOWPOSCHANGED
When minimizing a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_WINDOWPOSCHANGED - IsIconic() is true
WM_MOVE
WM_SIZE - SDL sees minimized state here

When restoring a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHANGED - IsIconic() is false
WM_MOVE
WM_SIZE - SDL sees restored state here

On Windows 10 a minimized window has a non-empty client rect, so we were delivering a minimized size before SDL knows that the window is minimized, and then ignoring the restored size when handling the restore message.

The fix is to use IsIconic() which returns the correct window state when WM_WINDOWPOSCHANGED is actually delivered.
2022-08-19 17:40:30 -07:00
69 changed files with 1144 additions and 710 deletions

View file

@ -64,7 +64,7 @@ jobs:
- name: Check that versioning is consistent
# We only need to run this once: arbitrarily use the Linux/CMake build
if: "runner.os == 'Linux' && ! matrix.platform.autotools"
run: ./test/versioning.sh
run: ./build-scripts/test-versioning.sh
- name: Configure (CMake)
if: "! matrix.platform.autotools"
run: |

View file

@ -66,7 +66,7 @@ jobs:
- name: Add msbuild to PATH
if: ${{ matrix.platform.project != '' }}
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v1.1.3
- name: Build msbuild
if: ${{ matrix.platform.project != '' }}
run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}

View file

@ -65,6 +65,7 @@ include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckStructHasMember)
include(CMakeDependentOption)
include(CMakePushCheckState)
include(FindPkgConfig)
include(GNUInstallDirs)
set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
@ -81,7 +82,7 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 24)
set(SDL_MICRO_VERSION 0)
set(SDL_MICRO_VERSION 2)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts
@ -482,7 +483,7 @@ endforeach()
set_option(SDL_WAYLAND "Use Wayland video driver" ${UNIX_SYS})
dep_option(SDL_WAYLAND_SHARED "Dynamically load Wayland support" ON "SDL_WAYLAND" OFF)
dep_option(SDL_WAYLAND_LIBDECOR "Use client-side window decorations on Wayland" ON "SDL_WAYLAND" OFF)
dep_option(SDL_WAYLAND_LIBDECOR_SHARED "Dynamically load libdecor support" ON "SDL_WAYLAND_LIBDECOR" OFF)
dep_option(SDL_WAYLAND_LIBDECOR_SHARED "Dynamically load libdecor support" ON "SDL_WAYLAND_LIBDECOR;SDL_WAYLAND_SHARED" OFF)
dep_option(SDL_WAYLAND_QT_TOUCH "QtWayland server support for Wayland video driver" ON "SDL_WAYLAND" OFF)
set_option(SDL_RPI "Use Raspberry Pi video driver" ${UNIX_SYS})
set_option(SDL_COCOA "Use Cocoa video driver" ${APPLE})
@ -505,9 +506,9 @@ dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" O
dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF)
set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF)
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static version of the library")
set(SDL_TEST ${SDL_TEST_ENABLED_BY_DEFAULT} CACHE BOOL "Build the SDL2_test library")
option(SDL_SHARED "Build a shared version of the library" ${SDL_SHARED_ENABLED_BY_DEFAULT})
option(SDL_STATIC "Build a static version of the library" ${SDL_STATIC_ENABLED_BY_DEFAULT})
option(SDL_TEST "Build the SDL2_test library" ${SDL_TEST_ENABLED_BY_DEFAULT})
dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" "${CMAKE_POSITION_INDEPENDENT_CODE}" "SDL_STATIC" OFF)
dep_option(SDL_TESTS "Build the test directory" OFF SDL_TEST OFF)
@ -1380,6 +1381,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
check_c_source_compiles("
#include <linux/kd.h>
#include <linux/keyboard.h>
#include <sys/ioctl.h>
int main(int argc, char **argv) {
struct kbentry kbe;
kbe.kb_table = KG_CTRL;
@ -3034,11 +3036,10 @@ if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN)
target_link_libraries(SDL2main PRIVATE shell32)
endif()
if(MINGW OR CYGWIN)
cmake_minimum_required(VERSION 3.13)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(SDL2main PUBLIC "-Wl,--undefined=_WinMain@16")
target_link_libraries(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>")
else()
target_link_options(SDL2main PUBLIC "-Wl,--undefined=WinMain")
target_link_libraries(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>")
endif()
endif()
if (NOT ANDROID)

View file

@ -13,7 +13,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 24
MICRO_VERSION = 0
MICRO_VERSION = 2
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2

View file

@ -4,9 +4,8 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 24
MICRO_VERSION = 0
MICRO_VERSION = 2
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2
LIBHOME = .
DLLFILE = $(LIBHOME)/$(LIBNAME).dll
@ -20,6 +19,8 @@ INCPATH+= -I"src/video/khronos"
LIBM = SDL2libm.lib
TLIB = SDL2test.lib
# user32.lib, gdi32.lib, ole32.lib and oleaut32.lib are actually
# among the default libraries in wlink.lnk for nt_dll linkage...
LIBS = user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib shell32.lib setupapi.lib version.lib uuid.lib dxguid.lib $(LIBM)
CFLAGS = -bt=nt -d0 -q -bm -5s -fp5 -fpi87 -sg -oeatxhn -ei
@ -253,7 +254,6 @@ $(LNKFILE): Makefile.w32
@%append $@ OPTION QUIET
@%append $@ OPTION IMPF=$(EXPFILE)
@%append $@ OPTION MAP=$(LIBHOME)/$^&.map
@%append $@ OPTION DESCRIPTION '@$#libsdl org:$(VERSION)$#@$(DESCRIPTION)'
@%append $@ OPTION ELIMINATE
@%append $@ OPTION SHOWDEAD

View file

@ -495,9 +495,6 @@
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
<Filter>haptic</Filter>
</ClInclude>
<ClInclude Include="..\..\src\hidapi\SDL_hidapi.h">
<Filter>hidapi</Filter>
</ClInclude>
<ClInclude Include="..\..\src\joystick\SDL_gamecontrollerdb.h">
<Filter>joystick</Filter>
</ClInclude>
@ -835,6 +832,7 @@
<ClInclude Include="..\..\src\render\direct3d12\SDL_shaders_d3d12.h">
<Filter>render\direct3d12</Filter>
</ClInclude>
<ClInclude Include="..\..\src\hidapi\SDL_hidapi_c.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\audio\wasapi\SDL_wasapi.c" />
@ -1351,6 +1349,7 @@
<ClCompile Include="..\..\src\render\direct3d12\SDL_shaders_d3d12.c">
<Filter>render\direct3d12</Filter>
</ClCompile>
<ClCompile Include="..\..\src\stdlib\SDL_mslibc.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\main\windows\version.rc" />

View file

@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.24.0</string>
<string>2.24.2</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.24.0</string>
<string>2.24.2</string>
</dict>
</plist>

View file

@ -9396,8 +9396,8 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
DYLIB_CURRENT_VERSION = 2401.0.0;
DYLIB_COMPATIBILITY_VERSION = 2401.0.0;
DYLIB_CURRENT_VERSION = 2401.2.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_ALTIVEC_EXTENSIONS = YES;
@ -9481,8 +9481,8 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
DYLIB_CURRENT_VERSION = 2401.0.0;
DYLIB_COMPATIBILITY_VERSION = 2401.0.0;
DYLIB_CURRENT_VERSION = 2401.2.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;

View file

@ -39,7 +39,7 @@ string(REGEX REPLACE "SDL2\\.framework.*" "" SDL2_FRAMEWORK_PARENT_PATH "${CMAKE
set_and_check(SDL2_PREFIX "${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_EXEC_PREFIX "${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_INCLUDE_DIR "${SDL2_FRAMEWORK_PATH}/Headers")
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}")
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR};${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_BINDIR "${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_LIBDIR "${SDL2_FRAMEWORK_PATH}")
@ -53,12 +53,17 @@ if(NOT TARGET SDL2::SDL2)
set_target_properties(SDL2::SDL2
PROPERTIES
INTERFACE_COMPILE_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\""
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2"
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
INTERFACE_SDL2_SHARED "ON"
)
endif()
set(SDL2_SDL2_FOUND)
set(SDL2_SDL2_FOUND TRUE)
if(NOT TARGET SDL2::SDL2main)
add_library(SDL2::SDL2main INTERFACE IMPORTED)
endif()
set(SDL2_SDL2main_FOUND TRUE)
check_required_components(SDL2)

View file

@ -104,10 +104,11 @@ int main (void)
else
AC_MSG_RESULT(no)
if test "$ESD_CONFIG" = "no" ; then
echo "*** The esd-config script installed by ESD could not be found"
echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the ESD_CONFIG environment variable to the"
echo "*** full path to esd-config."
dnl echo "*** The esd-config script installed by ESD could not be found"
dnl echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
dnl echo "*** your path, or set the ESD_CONFIG environment variable to the"
dnl echo "*** full path to esd-config."
:
else
if test -f conf.esdtest ; then
:

View file

@ -1075,7 +1075,7 @@ case $cpu-$vendor in
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
cpu=i586
;;
pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
cpu=i686
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)

View file

@ -34,6 +34,17 @@ else
not_ok "configure.ac $version disagrees with SDL_version.h $ref_version"
fi
major=$(sed -ne 's/^SDL_MAJOR_VERSION=//p' configure)
minor=$(sed -ne 's/^SDL_MINOR_VERSION=//p' configure)
micro=$(sed -ne 's/^SDL_MICRO_VERSION=//p' configure)
version="${major}.${minor}.${micro}"
if [ "$ref_version" = "$version" ]; then
ok "configure $version"
else
not_ok "configure $version disagrees with SDL_version.h $ref_version"
fi
major=$(sed -ne 's/^set(SDL_MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
minor=$(sed -ne 's/^set(SDL_MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
micro=$(sed -ne 's/^set(SDL_MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
@ -119,13 +130,25 @@ fi
# For simplicity this assumes we'll never break ABI before SDL 3.
dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
ref='1.0.0
1.0.0'
case "$ref_minor" in
(*[02468])
major="$(( ref_minor * 100 + 1 ))"
minor="0"
;;
(*)
major="$(( ref_minor * 100 + ref_micro + 1 ))"
minor="0"
;;
esac
ref="${major}.${minor}.0
${major}.${minor}.0"
if [ "$ref" = "$dylib_compat" ]; then
ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is consistent"
else
not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent"
not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent, expected $ref, got $dylib_compat"
fi
dylib_cur=$(sed -Ene 's/.*DYLIB_CURRENT_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
@ -147,7 +170,7 @@ ${major}.${minor}.0"
if [ "$ref" = "$dylib_cur" ]; then
ok "project.pbxproj DYLIB_CURRENT_VERSION is consistent"
else
not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent"
not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent, expected $ref, got $dylib_cur"
fi
echo "1..$tests"

88
build-scripts/update-version.sh Executable file
View file

@ -0,0 +1,88 @@
#!/bin/sh
#set -x
cd `dirname $0`/..
ARGSOKAY=1
if [ -z $1 ]; then
ARGSOKAY=0
fi
if [ -z $2 ]; then
ARGSOKAY=0
fi
if [ -z $3 ]; then
ARGSOKAY=0
fi
if [ "x$ARGSOKAY" = "x0" ]; then
echo "USAGE: $0 <major> <minor> <patch>" 1>&2
exit 1
fi
MAJOR="$1"
MINOR="$2"
PATCH="$3"
NEWVERSION="$MAJOR.$MINOR.$PATCH"
echo "Updating version to '$NEWVERSION' ..."
# !!! FIXME: This first one is a kinda scary search/replace that might fail later if another X.Y.Z version is added to the file.
perl -w -pi -e 's/(\<string\>)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/Info-Framework.plist
DYVER=`expr $MINOR \* 100 + 1`
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
# Set compat to major.minor.0 by default.
perl -w -pi -e 's/(DYLIB_COMPATIBILITY_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
# non-zero patch?
if [ "x$PATCH" != "x0" ]; then
if [ `expr $MINOR % 2` = "0" ]; then
# If patch is not zero, but minor is even, it's a bugfix release.
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.'$PATCH'.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
else
# If patch is not zero, but minor is odd, it's a development prerelease.
DYVER=`expr $MINOR \* 100 + $PATCH + 1`
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
perl -w -pi -e 's/(DYLIB_COMPATIBILITY_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
fi
fi
perl -w -pi -e 's/\A(SDL_MAJOR_VERSION=)\d+/${1}'$MAJOR'/;' configure.ac
perl -w -pi -e 's/\A(SDL_MINOR_VERSION=)\d+/${1}'$MINOR'/;' configure.ac
perl -w -pi -e 's/\A(SDL_MICRO_VERSION=)\d+/${1}'$PATCH'/;' configure.ac
perl -w -pi -e 's/\A(set\(SDL_MAJOR_VERSION\s+)\d+/${1}'$MAJOR'/;' CMakeLists.txt
perl -w -pi -e 's/\A(set\(SDL_MINOR_VERSION\s+)\d+/${1}'$MINOR'/;' CMakeLists.txt
perl -w -pi -e 's/\A(set\(SDL_MICRO_VERSION\s+)\d+/${1}'$PATCH'/;' CMakeLists.txt
perl -w -pi -e 's/\A(MAJOR_VERSION\s*=\s*)\d+/${1}'$MAJOR'/;' Makefile.os2
perl -w -pi -e 's/\A(MINOR_VERSION\s*=\s*)\d+/${1}'$MINOR'/;' Makefile.os2
perl -w -pi -e 's/\A(MICRO_VERSION\s*=\s*)\d+/${1}'$PATCH'/;' Makefile.os2
perl -w -pi -e 's/\A(MAJOR_VERSION\s*=\s*)\d+/${1}'$MAJOR'/;' Makefile.w32
perl -w -pi -e 's/\A(MINOR_VERSION\s*=\s*)\d+/${1}'$MINOR'/;' Makefile.w32
perl -w -pi -e 's/\A(MICRO_VERSION\s*=\s*)\d+/${1}'$PATCH'/;' Makefile.w32
perl -w -pi -e 's/(\#define SDL_MAJOR_VERSION\s+)\d+/${1}'$MAJOR'/;' include/SDL_version.h
perl -w -pi -e 's/(\#define SDL_MINOR_VERSION\s+)\d+/${1}'$MINOR'/;' include/SDL_version.h
perl -w -pi -e 's/(\#define SDL_PATCHLEVEL\s+)\d+/${1}'$PATCH'/;' include/SDL_version.h
perl -w -pi -e 's/(FILEVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$PATCH'/;' src/main/windows/version.rc
perl -w -pi -e 's/(PRODUCTVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$PATCH'/;' src/main/windows/version.rc
perl -w -pi -e 's/(VALUE "FileVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$PATCH'/;' src/main/windows/version.rc
perl -w -pi -e 's/(VALUE "ProductVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$PATCH'/;' src/main/windows/version.rc
echo "Regenerating configure script with new version..."
./autogen.sh |grep -v 'Now you are ready to run ./configure'
echo "Running build-scripts/test-versioning.sh to verify changes..."
./build-scripts/test-versioning.sh
echo "All done."
echo "Run 'git diff' and make sure this looks correct, before 'git commit'."
exit 0

View file

@ -96,7 +96,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")
CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR})
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VAR})
set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
endmacro()
else()

View file

@ -1,8 +1,11 @@
include(CMakeParseArguments)
macro(FindLibraryAndSONAME _LIB)
cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN})
string(TOUPPER ${_LIB} _UPPERLNAME)
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
find_library(${_LNAME}_LIB ${_LIB})
find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS})
if(${_LNAME}_LIB)
# reduce the library name for shared linking
@ -30,28 +33,19 @@ macro(FindLibraryAndSONAME _LIB)
endmacro()
macro(CheckDLOPEN)
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
if(NOT HAVE_DLOPEN)
check_library_exists(dl dlopen "" DLOPEN_LIB)
if(DLOPEN_LIB)
cmake_push_check_state(RESET)
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBC)
if(NOT HAVE_DLOPEN_IN_LIBC)
set(CMAKE_REQUIRED_LIBRARIES dl)
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBDL)
if(HAVE_DLOPEN_IN_LIBDL)
list(APPEND EXTRA_LIBS dl)
set(_DLLIB dl)
set(HAVE_DLOPEN TRUE)
endif()
endif()
if(HAVE_DLOPEN)
if(_DLLIB)
set(CMAKE_REQUIRED_LIBRARIES ${_DLLIB})
endif()
check_c_source_compiles("
#include <dlfcn.h>
int main(int argc, char **argv) {
void *handle = dlopen(\"\", RTLD_NOW);
const char *loaderror = (char *) dlerror();
return 0;
}" HAVE_DLOPEN)
set(CMAKE_REQUIRED_LIBRARIES)
if(HAVE_DLOPEN_IN_LIBC OR HAVE_DLOPEN_IN_LIBDL)
set(HAVE_DLOPEN TRUE)
endif()
cmake_pop_check_state()
endmacro()
macro(CheckO_CLOEXEC)
@ -140,7 +134,7 @@ macro(CheckPipewire)
if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
endif()
FindLibraryAndSONAME("pipewire-0.3")
FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PKG_PIPEWIRE_LIBRARY_DIRS})
if(SDL_PIPEWIRE_SHARED AND PIPEWIRE_0.3_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
set(HAVE_PIPEWIRE_SHARED TRUE)
@ -169,7 +163,7 @@ macro(CheckPulseAudio)
if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
endif()
FindLibraryAndSONAME("pulse-simple")
FindLibraryAndSONAME("pulse-simple" LIBDIRS ${PKG_PULSEAUDIO_LIBRARY_DIRS})
if(SDL_PULSEAUDIO_SHARED AND PULSE_SIMPLE_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
set(HAVE_PULSEAUDIO_SHARED TRUE)
@ -198,7 +192,7 @@ macro(CheckJACK)
if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
endif()
FindLibraryAndSONAME("jack")
FindLibraryAndSONAME("jack" LIBDIRS ${PKG_JACK_LIBRARY_DIRS})
if(SDL_JACK_SHARED AND JACK_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
set(HAVE_JACK_SHARED TRUE)
@ -227,7 +221,7 @@ macro(CheckESD)
if(SDL_ESD_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
endif()
FindLibraryAndSONAME(esd)
FindLibraryAndSONAME(esd LIBDIRS ${PKG_ESD_LIBRARY_DIRS})
if(SDL_ESD_SHARED AND ESD_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
set(HAVE_ESD_SHARED TRUE)
@ -321,7 +315,7 @@ macro(CheckSNDIO)
if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
endif()
FindLibraryAndSONAME("sndio")
FindLibraryAndSONAME("sndio" LIBDIRS ${PKG_SNDIO_LIBRARY_DIRS})
if(SDL_SNDIO_SHARED AND SNDIO_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
set(HAVE_SNDIO_SHARED TRUE)
@ -350,7 +344,7 @@ macro(CheckFusionSound)
if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
endif()
FindLibraryAndSONAME("fusionsound")
FindLibraryAndSONAME("fusionsound" LIBDIRS ${PKG_FUSIONSOUND_LIBRARY_DIRS})
if(FUSIONSOUND_SHARED AND FUSIONSOUND_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
set(HAVE_FUSIONSOUND_SHARED TRUE)
@ -646,9 +640,11 @@ endmacro()
# - HAVE_SDL_LOADSO opt
macro(CheckWayland)
if(SDL_WAYLAND)
pkg_check_modules(WAYLAND "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
set(WAYLAND_FOUND FALSE)
pkg_check_modules(PKG_WAYLAND "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
if(WAYLAND_FOUND)
if(PKG_WAYLAND_FOUND)
set(WAYLAND_FOUND TRUE)
find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED)
execute_process(
COMMAND ${WAYLAND_SCANNER} --version
@ -671,8 +667,8 @@ macro(CheckWayland)
endif()
if(WAYLAND_FOUND)
target_link_directories(sdl-build-options INTERFACE "${WAYLAND_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${WAYLAND_INCLUDE_DIRS}")
target_link_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_INCLUDE_DIRS}")
set(HAVE_WAYLAND TRUE)
set(HAVE_SDL_VIDEO TRUE)
@ -698,10 +694,10 @@ macro(CheckWayland)
if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
endif()
FindLibraryAndSONAME(wayland-client)
FindLibraryAndSONAME(wayland-egl)
FindLibraryAndSONAME(wayland-cursor)
FindLibraryAndSONAME(xkbcommon)
FindLibraryAndSONAME(wayland-client LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
FindLibraryAndSONAME(wayland-egl LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
FindLibraryAndSONAME(wayland-cursor LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
FindLibraryAndSONAME(xkbcommon LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
if(SDL_WAYLAND_SHARED AND WAYLAND_CLIENT_LIB AND WAYLAND_EGL_LIB AND WAYLAND_CURSOR_LIB AND XKBCOMMON_LIB AND HAVE_SDL_LOADSO)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
@ -709,25 +705,25 @@ macro(CheckWayland)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
set(HAVE_WAYLAND_SHARED TRUE)
else()
list(APPEND EXTRA_LIBS ${WAYLAND_LIBRARIES})
list(APPEND EXTRA_LIBS ${PKG_WAYLAND_LIBRARIES})
endif()
if(SDL_WAYLAND_LIBDECOR)
pkg_check_modules(LIBDECOR libdecor-0)
if(LIBDECOR_FOUND)
pkg_check_modules(PKG_LIBDECOR libdecor-0)
if(PKG_LIBDECOR_FOUND)
set(HAVE_WAYLAND_LIBDECOR TRUE)
set(HAVE_LIBDECOR_H 1)
target_link_directories(sdl-build-options INTERFACE "${LIBDECOR_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${LIBDECOR_INCLUDE_DIRS}")
target_link_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_INCLUDE_DIRS}")
if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
endif()
FindLibraryAndSONAME(decor-0)
FindLibraryAndSONAME(decor-0 LIBDIRS ${PKG_LIBDECOR_LIBRARY_DIRS})
if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO)
set(HAVE_LIBDECOR_SHARED TRUE)
set(HAVE_WAYLAND_LIBDECOR_SHARED TRUE)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
else()
list(APPEND EXTRA_LIBS ${LIBDECOR_LIBRARIES})
list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES})
endif()
endif()
endif()
@ -773,7 +769,7 @@ macro(CheckDirectFB)
if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
endif()
FindLibraryAndSONAME("directfb")
FindLibraryAndSONAME("directfb" LIBDIRS ${PKG_DIRECTFB_LIBRARY_DIRS})
if(SDL_DIRECTFB_SHARED AND DIRECTFB_LIB AND HAVE_SDL_LOADSO)
set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
set(HAVE_DIRECTFB_SHARED TRUE)
@ -1179,19 +1175,19 @@ macro(CheckHIDAPI)
if(SDL_HIDAPI)
if(SDL_HIDAPI_LIBUSB)
set(HAVE_LIBUSB FALSE)
pkg_check_modules(LIBUSB libusb-1.0)
if(LIBUSB_FOUND)
check_include_file(libusb.h HAVE_LIBUSB_H ${LIBUSB_CFLAGS})
pkg_check_modules(PKG_LIBUSB libusb-1.0)
if(PKG_LIBUSB_FOUND)
check_include_file(libusb.h HAVE_LIBUSB_H ${PKG_LIBUSB_CFLAGS})
if(HAVE_LIBUSB_H)
set(HAVE_LIBUSB TRUE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PKG_LIBUSB_CFLAGS}")
if(HIDAPI_ONLY_LIBUSB)
list(APPEND EXTRA_LIBS ${LIBUSB_LIBS})
list(APPEND EXTRA_LIBS ${PKG_LIBUSB_LIBRARIES})
elseif(OS2)
set(SDL_LIBUSB_DYNAMIC "\"usb100.dll\"")
else()
# libusb is loaded dynamically, so don't add it to EXTRA_LIBS
FindLibraryAndSONAME("usb-1.0")
FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PKG_LIBUSB_LIBRARY_DIRS})
if(USB_1.0_LIB)
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
endif()
@ -1201,6 +1197,7 @@ macro(CheckHIDAPI)
if(HIDAPI_ONLY_LIBUSB AND NOT HAVE_LIBUSB)
set(HAVE_HIDAPI FALSE)
endif()
set(HAVE_HIDAPI_LIBUSB ${HAVE_LIBUSB})
endif()
if(HAVE_HIDAPI)
@ -1220,6 +1217,8 @@ macro(CheckHIDAPI)
file(GLOB HIDAPI_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
list(APPEND SOURCE_FILES ${HIDAPI_JOYSTICK_SOURCES})
endif()
else()
set(SDL_HIDAPI_DISABLED 1)
endif()
else()
set(SDL_HIDAPI_DISABLED 1)
@ -1274,19 +1273,17 @@ endmacro()
# - HAVE_SDL_LOADSO opt
macro(CheckKMSDRM)
if(SDL_KMSDRM)
pkg_check_modules(KMSDRM libdrm gbm egl)
if(KMSDRM_FOUND AND HAVE_OPENGL_EGL)
link_directories(
${KMSDRM_LIBRARY_DIRS}
)
target_include_directories(sdl-build-options INTERFACE "${KMSDRM_INCLUDE_DIRS}")
pkg_check_modules(PKG_KMSDRM libdrm gbm egl)
if(PKG_KMSDRM_FOUND AND HAVE_OPENGL_EGL)
target_link_directories(sdl-build-options INTERFACE ${PKG_KMSDRM_LIBRARY_DIRS})
target_include_directories(sdl-build-options INTERFACE "${PKG_KMSDRM_INCLUDE_DIRS}")
set(HAVE_KMSDRM TRUE)
set(HAVE_SDL_VIDEO TRUE)
file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c)
list(APPEND SOURCE_FILES ${KMSDRM_SOURCES})
list(APPEND EXTRA_CFLAGS ${KMSDRM_CFLAGS})
list(APPEND EXTRA_CFLAGS ${PKG_KMSDRM_CFLAGS})
set(SDL_VIDEO_DRIVER_KMSDRM 1)
@ -1294,13 +1291,13 @@ macro(CheckKMSDRM)
message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
endif()
if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME(drm)
FindLibraryAndSONAME(gbm)
FindLibraryAndSONAME(drm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
FindLibraryAndSONAME(gbm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
set(HAVE_KMSDRM_SHARED TRUE)
else()
list(APPEND EXTRA_LIBS ${KMSDRM_LIBRARIES})
list(APPEND EXTRA_LIBS ${PKG_KMSDRM_LIBRARIES})
endif()
endif()
endif()

View file

@ -3,6 +3,8 @@
cmake_minimum_required(VERSION 3.12)
project(sdl_test LANGUAGES C)
include(GenerateExportHeader)
if(ANDROID)
macro(add_executable NAME)
set(args ${ARGN})
@ -41,6 +43,12 @@ if(TEST_SHARED)
)
endif()
add_library(sharedlib-shared SHARED main_lib.c)
target_link_libraries(sharedlib-shared PRIVATE SDL2::SDL2)
generate_export_header(sharedlib-shared EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-shared PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared_export.h\"")
set_target_properties(sharedlib-shared PROPERTIES C_VISIBILITY_PRESET "hidden")
add_executable(gui-shared-vars WIN32 main_gui.c)
target_link_libraries(gui-shared-vars PRIVATE ${SDL2_LIBRARIES})
target_include_directories(gui-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS})
@ -60,6 +68,13 @@ if(TEST_SHARED)
target_link_libraries(cli-shared-vars PRIVATE ${SDL2_LIBRARIES})
target_include_directories(cli-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS})
endif()
add_library(sharedlib-shared-vars SHARED main_lib.c)
target_link_libraries(sharedlib-shared-vars PRIVATE ${SDL2_LIBRARIES})
target_include_directories(sharedlib-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS})
generate_export_header(sharedlib-shared-vars EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-shared-vars PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared-vars_export.h\"")
set_target_properties(sharedlib-shared-vars PROPERTIES C_VISIBILITY_PRESET "hidden")
endif()
if(TEST_STATIC)
@ -73,6 +88,15 @@ if(TEST_STATIC)
endif()
target_link_libraries(gui-static PRIVATE SDL2::SDL2-static)
option(SDL_STATIC_PIC "SDL static library has been built with PIC")
if(SDL_STATIC_PIC OR WIN32)
add_library(sharedlib-static SHARED main_lib.c)
target_link_libraries(sharedlib-static PRIVATE SDL2::SDL2-static)
generate_export_header(sharedlib-static EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-static PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-static_export.h\"")
set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden")
endif()
add_executable(gui-static-vars WIN32 main_gui.c)
target_link_libraries(gui-static-vars PRIVATE ${SDL2MAIN_LIBRARY} ${SDL2_STATIC_LIBRARIES})
target_include_directories(gui-static-vars PRIVATE ${SDL2_INCLUDE_DIRS})

33
cmake/test/main_lib.c Normal file
View file

@ -0,0 +1,33 @@
#include "SDL.h"
#include <stdio.h>
#include EXPORT_HEADER
#if defined(_WIN32)
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
return TRUE;
}
#endif
int MYLIBRARY_EXPORT mylibrary_init(void);
void MYLIBRARY_EXPORT mylibrary_quit(void);
int MYLIBRARY_EXPORT mylibrary_work(void);
int mylibrary_init(void) {
SDL_SetMainReady();
if (SDL_Init(0) < 0) {
fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError());
return 1;
}
return 0;
}
void mylibrary_quit(void) {
SDL_Quit();
}
int mylibrary_work(void) {
SDL_Delay(100);
return 0;
}

389
configure vendored
View file

@ -657,6 +657,7 @@ ac_includes_default="\
ac_header_c_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
WAYLAND_SCANNER_CODE_MODE
WAYLAND_SCANNER
EXTRA_LDFLAGS
@ -711,19 +712,18 @@ PULSEAUDIO_LIBS
PULSEAUDIO_CFLAGS
PIPEWIRE_LIBS
PIPEWIRE_CFLAGS
ESD_CONFIG
ESD_LIBS
ESD_CFLAGS
ESD_CONFIG
JACK_LIBS
JACK_CFLAGS
ALSA_LIBS
ALSA_CFLAGS
POW_LIB
LIBOBJS
ALLOCA
CPP
LIBTOOLLINKERTAG
LINKER
SORT
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
@ -970,6 +970,8 @@ PKG_CONFIG_LIBDIR
CPP
JACK_CFLAGS
JACK_LIBS
ESD_CFLAGS
ESD_LIBS
PIPEWIRE_CFLAGS
PIPEWIRE_LIBS
PULSEAUDIO_CFLAGS
@ -1809,6 +1811,8 @@ Some influential environment variables:
CPP C preprocessor
JACK_CFLAGS C compiler flags for JACK, overriding pkg-config
JACK_LIBS linker flags for JACK, overriding pkg-config
ESD_CFLAGS C compiler flags for ESD, overriding pkg-config
ESD_LIBS linker flags for ESD, overriding pkg-config
PIPEWIRE_CFLAGS
C compiler flags for PIPEWIRE, overriding pkg-config
PIPEWIRE_LIBS
@ -3434,7 +3438,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=24
SDL_MICRO_VERSION=0
SDL_MICRO_VERSION=2
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
@ -17898,6 +17902,60 @@ if test -z "$AWK" ; then
as_fn_error $? "*** awk not found, aborting" "$LINENO" 5
fi
for ac_prog in gsort sort
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_prog_SORT+y}
then :
printf %s "(cached) " >&6
else $as_nop
if test -n "$SORT"; then
ac_cv_prog_SORT="$SORT" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_prog_SORT="$ac_prog"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
SORT=$ac_cv_prog_SORT
if test -n "$SORT"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5
printf "%s\n" "$SORT" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
test -n "$SORT" && break
done
test -n "$SORT" || SORT="false"
if ! "$SORT" -V </dev/null >/dev/null
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: sort(1) that supports the -V option is required to find dynamic libraries" >&5
printf "%s\n" "$as_me: WARNING: sort(1) that supports the -V option is required to find dynamic libraries" >&2;}
fi
# Check whether --enable-largefile was given.
if test ${enable_largefile+y}
then :
@ -18227,7 +18285,7 @@ find_lib()
host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
fi
for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
lib=`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | sort -V -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | sort -n -s | sed 's,[0-9]* ,,' | head -1`
lib=`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | "$SORT" -V -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | "$SORT" -n -s | sed 's,[0-9]* ,,' | head -1`
if test x$lib != x; then
echo $lib
return
@ -19064,198 +19122,6 @@ printf "%s\n" "#define STACK_DIRECTION $ac_cv_c_stack_direction" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5
printf %s "checking for working memcmp... " >&6; }
if test ${ac_cv_func_memcmp_working+y}
then :
printf %s "(cached) " >&6
else $as_nop
if test "$cross_compiling" = yes
then :
ac_cv_func_memcmp_working=no
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
int
main (void)
{
/* Some versions of memcmp are not 8-bit clean. */
char c0 = '\100', c1 = '\200', c2 = '\201';
if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
return 1;
/* The Next x86 OpenStep bug shows up only when comparing 16 bytes
or more and with at least one buffer not starting on a 4-byte boundary.
William Lewis provided this test program. */
{
char foo[21];
char bar[21];
int i;
for (i = 0; i < 4; i++)
{
char *a = foo + i;
char *b = bar + i;
strcpy (a, "--------01111111");
strcpy (b, "--------10000000");
if (memcmp (a, b, 16) >= 0)
return 1;
}
return 0;
}
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"
then :
ac_cv_func_memcmp_working=yes
else $as_nop
ac_cv_func_memcmp_working=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_memcmp_working" >&5
printf "%s\n" "$ac_cv_func_memcmp_working" >&6; }
test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in
*" memcmp.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS memcmp.$ac_objext"
;;
esac
if test x$ac_cv_func_memcmp_working = xyes; then
printf "%s\n" "#define HAVE_MEMCMP 1" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5
printf %s "checking for working strtod... " >&6; }
if test ${ac_cv_func_strtod+y}
then :
printf %s "(cached) " >&6
else $as_nop
if test "$cross_compiling" = yes
then :
ac_cv_func_strtod=no
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
#ifndef strtod
double strtod ();
#endif
int
main (void)
{
{
/* Some versions of Linux strtod mis-parse strings with leading '+'. */
char *string = " +69";
char *term;
double value;
value = strtod (string, &term);
if (value != 69 || term != (string + 4))
return 1;
}
{
/* Under Solaris 2.4, strtod returns the wrong value for the
terminating character under some conditions. */
char *string = "NaN";
char *term;
strtod (string, &term);
if (term != string && *(term - 1) == 0)
return 1;
}
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"
then :
ac_cv_func_strtod=yes
else $as_nop
ac_cv_func_strtod=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5
printf "%s\n" "$ac_cv_func_strtod" >&6; }
if test $ac_cv_func_strtod = no; then
case " $LIBOBJS " in
*" strtod.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS strtod.$ac_objext"
;;
esac
ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow"
if test "x$ac_cv_func_pow" = xyes
then :
fi
if test $ac_cv_func_pow = no; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5
printf %s "checking for pow in -lm... " >&6; }
if test ${ac_cv_lib_m_pow+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_check_lib_save_LIBS=$LIBS
LIBS="-lm $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
char pow ();
int
main (void)
{
return pow ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_m_pow=yes
else $as_nop
ac_cv_lib_m_pow=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5
printf "%s\n" "$ac_cv_lib_m_pow" >&6; }
if test "x$ac_cv_lib_m_pow" = xyes
then :
POW_LIB=-lm
else $as_nop
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5
printf "%s\n" "$as_me: WARNING: cannot find library containing definition of pow" >&2;}
fi
fi
fi
if test x$ac_cv_func_strtod = xyes; then
printf "%s\n" "#define HAVE_STRTOD 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "mprotect" "ac_cv_func_mprotect"
if test "x$ac_cv_func_mprotect" = xyes
then :
@ -19361,6 +19227,12 @@ if test "x$ac_cv_func_memset" = xyes
then :
printf "%s\n" "#define HAVE_MEMSET 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "memcmp" "ac_cv_func_memcmp"
if test "x$ac_cv_func_memcmp" = xyes
then :
printf "%s\n" "#define HAVE_MEMCMP 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "memcpy" "ac_cv_func_memcpy"
if test "x$ac_cv_func_memcpy" = xyes
@ -19541,6 +19413,12 @@ if test "x$ac_cv_func__ultoa" = xyes
then :
printf "%s\n" "#define HAVE__ULTOA 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "strtod" "ac_cv_func_strtod"
if test "x$ac_cv_func_strtod" = xyes
then :
printf "%s\n" "#define HAVE_STRTOD 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "strtol" "ac_cv_func_strtol"
if test "x$ac_cv_func_strtol" = xyes
@ -21583,6 +21461,78 @@ fi
if test x$enable_audio = xyes -a x$enable_esd = xyes; then
pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for esound >= 0.2.8" >&5
printf %s "checking for esound >= 0.2.8... " >&6; }
if test -n "$ESD_CFLAGS"; then
pkg_cv_ESD_CFLAGS="$ESD_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"esound >= 0.2.8\""; } >&5
($PKG_CONFIG --exists --print-errors "esound >= 0.2.8") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ESD_CFLAGS=`$PKG_CONFIG --cflags "esound >= 0.2.8" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$ESD_LIBS"; then
pkg_cv_ESD_LIBS="$ESD_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"esound >= 0.2.8\""; } >&5
($PKG_CONFIG --exists --print-errors "esound >= 0.2.8") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ESD_LIBS=`$PKG_CONFIG --libs "esound >= 0.2.8" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
ESD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "esound >= 0.2.8" 2>&1`
else
ESD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "esound >= 0.2.8" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$ESD_PKG_ERRORS" >&5
have_esd=no
elif test $pkg_failed = untried; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
have_esd=no
else
ESD_CFLAGS=$pkg_cv_ESD_CFLAGS
ESD_LIBS=$pkg_cv_ESD_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
have_esd=yes
fi
if test x$have_esd = xno; then
# Check whether --with-esd-prefix was given.
if test ${with_esd_prefix+y}
then :
@ -21766,10 +21716,7 @@ printf "%s\n" "yes" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
if test "$ESD_CONFIG" = "no" ; then
echo "*** The esd-config script installed by ESD could not be found"
echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the ESD_CONFIG environment variable to the"
echo "*** full path to esd-config."
:
else
if test -f conf.esdtest ; then
:
@ -21834,6 +21781,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
rm -f conf.esdtest
fi
if test x$have_esd = xyes; then
# Check whether --enable-esd-shared was given.
if test ${enable_esd_shared+y}
@ -22826,6 +22774,41 @@ printf "%s\n" "$have_clang_objc_arc" >&6; }
fi
}
CheckGDwarf4()
{
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -gdwarf-4 option" >&5
printf %s "checking for GCC -gdwarf-4 option... " >&6; }
have_gcc_gdwarf4=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -gdwarf-4"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int x = 0;
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_gcc_gdwarf4=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_gdwarf4" >&5
printf "%s\n" "$have_gcc_gdwarf4" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_gdwarf4 = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -gdwarf-4"
fi
}
CheckVisibilityHidden()
{
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5
@ -26120,6 +26103,7 @@ printf %s "checking for Linux kd.h... " >&6; }
#include <linux/kd.h>
#include <linux/keyboard.h>
#include <sys/ioctl.h>
int
main (void)
@ -28015,6 +27999,8 @@ fi
if test x$hidapi_support = xyes; then
if test x$have_libusb_h = xyes; then
printf "%s\n" "#define HAVE_LIBUSB 1" >>confdefs.h
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
if test x$require_hidapi_libusb = xyes; then
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
@ -28552,6 +28538,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h
if test x$enable_loadso = xyes; then
have_loadso=yes
fi
CheckGDwarf4
CheckDeclarationAfterStatement
CheckDummyVideo
CheckOffscreenVideo

View file

@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=24
SDL_MICRO_VERSION=0
SDL_MICRO_VERSION=2
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
@ -70,6 +70,9 @@ if [ test -z "$AWK" ]; then
AC_MSG_ERROR([*** awk not found, aborting])
fi
AC_CHECK_PROGS([SORT], [gsort sort], [false])
AS_IF([! "$SORT" -V </dev/null >/dev/null], [AC_MSG_WARN([sort(1) that supports the -V option is required to find dynamic libraries])])
dnl 64-bit file offsets if possible unless --disable-largefile is specified
AC_SYS_LARGEFILE
@ -186,7 +189,7 @@ find_lib()
host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
fi
for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
lib=[`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | sort -V -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | sort -n -s | sed 's,[0-9]* ,,' | head -1`]
lib=[`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | "$SORT" -V -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | "$SORT" -n -s | sed 's,[0-9]* ,,' | head -1`]
if test x$lib != x; then
echo $lib
return
@ -331,14 +334,6 @@ dnl Check for defines
AC_FUNC_ALLOCA
dnl Checks for library functions.
AC_FUNC_MEMCMP
if test x$ac_cv_func_memcmp_working = xyes; then
AC_DEFINE(HAVE_MEMCMP, 1, [ ])
fi
AC_FUNC_STRTOD
if test x$ac_cv_func_strtod = xyes; then
AC_DEFINE(HAVE_STRTOD, 1, [ ])
fi
AC_CHECK_FUNC(mprotect,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
@ -347,7 +342,7 @@ dnl Checks for library functions.
AC_DEFINE(HAVE_MPROTECT, 1, [ ])
],[]),
)
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit)
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit)
AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
@ -1062,7 +1057,10 @@ CheckESD()
[AS_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [default=yes]])],
, enable_esd=yes)
if test x$enable_audio = xyes -a x$enable_esd = xyes; then
AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
PKG_CHECK_MODULES([ESD], [esound >= 0.2.8], have_esd=yes, have_esd=no)
if test x$have_esd = xno; then
AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
fi
if test x$have_esd = xyes; then
AC_ARG_ENABLE(esd-shared,
[AS_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [default=yes]])],
@ -1517,6 +1515,26 @@ CheckObjectiveCARC()
fi
}
dnl See if GCC's -gdwarf-4 is supported
dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101377 for why this is needed on Windows
CheckGDwarf4()
{
AC_MSG_CHECKING(for GCC -gdwarf-4 option)
have_gcc_gdwarf4=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -gdwarf-4"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
int x = 0;
]],[])], [have_gcc_gdwarf4=yes],[])
AC_MSG_RESULT($have_gcc_gdwarf4)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_gdwarf4 = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -gdwarf-4"
fi
}
dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
CheckVisibilityHidden()
@ -2725,6 +2743,7 @@ CheckInputKD()
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <linux/kd.h>
#include <linux/keyboard.h>
#include <sys/ioctl.h>
]], [[
struct kbentry kbe;
kbe.kb_table = KG_CTRL;
@ -3578,6 +3597,7 @@ CheckHIDAPI()
if test x$hidapi_support = xyes; then
if test x$have_libusb_h = xyes; then
AC_DEFINE(HAVE_LIBUSB)
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
if test x$require_hidapi_libusb = xyes; then
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
@ -3968,6 +3988,7 @@ case "$host" in
if test x$enable_loadso = xyes; then
have_loadso=yes
fi
CheckGDwarf4
CheckDeclarationAfterStatement
CheckDummyVideo
CheckOffscreenVideo

View file

@ -1,31 +1,18 @@
# Release checklist
When changing the version, run `build-scripts/update-version.sh X Y Z`,
where `X Y Z` are the major version, minor version, and patch level. So
`2 28 1` means "change the version to 2.28.1". This script does much of the
mechanical work.
## New feature release
* Update `WhatsNew.txt`
* Bump version number to 2.EVEN.0 in all these locations:
* Bump version number to 2.EVEN.0:
* `configure.ac`, `CMakeLists.txt`: `SDL_*_VERSION`
* `Xcode/SDL/Info-Framework.plist`: `CFBundleShortVersionString`,
`CFBundleVersion`
* `Makefile.os2`: `VERSION`
* `Makefile.w32`: `*_VERSION`
* `include/SDL_version.h`: `SDL_*_VERSION`, `SDL_PATCHLEVEL`
* `src/main/windows/version.rc`: `FILEVERSION`, `PRODUCTVERSION`,
`FileVersion`, `ProductVersion`
* Bump ABI version information
* `CMakeLists.txt`, `Xcode/SDL/SDL.xcodeproj/project.pbxproj`:
`DYLIB_CURRENT_VERSION`, `DYLIB_COMPATIBILITY_VERSION`
* set first number in `DYLIB_CURRENT_VERSION` to
(100 * *minor*) + 1
* set second number in `DYLIB_CURRENT_VERSION` to 0
* if backwards compatibility has been broken,
increase `DYLIB_COMPATIBILITY_VERSION` (?)
* Run test/versioning.sh to verify that everything is consistent
* `./build-scripts/update-version.sh 2 EVEN 0`
* Regenerate `configure`
@ -39,15 +26,7 @@
* Bump version number from 2.Y.Z to 2.Y.(Z+1) (Y is even)
* Same places as listed above
* Bump ABI version information
* `CMakeLists.txt`, `Xcode/SDL/SDL.xcodeproj/project.pbxproj`:
`DYLIB_CURRENT_VERSION`, `DYLIB_COMPATIBILITY_VERSION`
* set second number in `DYLIB_CURRENT_VERSION` to *patchlevel*
* Run test/versioning.sh to verify that everything is consistent
* `./build-scripts/update-version.sh 2 Y Z+1`
* Regenerate `configure`
@ -59,32 +38,13 @@
* Bump version number to 2.ODD.0 for next development branch
* Same places as listed above
* Bump ABI version information
* Same places as listed above
* Assume that the next feature release will contain new API/ABI
* Run test/versioning.sh to verify that everything is consistent
* `./build-scripts/update-version.sh 2 ODD 0`
## New development prerelease
* Bump version number from 2.Y.Z to 2.Y.(Z+1) (Y is odd)
* Same places as listed above
* Bump ABI version information
* `CMakeLists.txt`, `Xcode/SDL/SDL.xcodeproj/project.pbxproj`:
`DYLIB_CURRENT_VERSION`, `DYLIB_COMPATIBILITY_VERSION`
* set first number in `DYLIB_CURRENT_VERSION` to
(100 * *minor*) + *patchlevel* + 1
* set second number in `DYLIB_CURRENT_VERSION` to 0
* if backwards compatibility has been broken,
increase `DYLIB_COMPATIBILITY_VERSION` (?)
* Run test/versioning.sh to verify that everything is consistent
* `./build-scripts/update-version.sh 2 Y Z+1`
* Regenerate `configure`

View file

@ -240,7 +240,7 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */
#elif (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__)
#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
#define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")
#elif (defined(__powerpc__) || defined(__powerpc64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");

View file

@ -224,6 +224,7 @@
#cmakedefine HAVE_INOTIFY_INIT 1
#cmakedefine HAVE_INOTIFY_INIT1 1
#cmakedefine HAVE_INOTIFY 1
#cmakedefine HAVE_LIBUSB 1
#cmakedefine HAVE_O_CLOEXEC 1
/* Apple platforms might be building universal binaries, where Intel builds

View file

@ -227,6 +227,7 @@
#undef HAVE_IBUS_IBUS_H
#undef HAVE_IMMINTRIN_H
#undef HAVE_LIBUDEV_H
#undef HAVE_LIBUSB
#undef HAVE_LIBSAMPLERATE_H
#undef HAVE_LIBDECOR_H
#undef HAVE_LSXINTRIN_H

View file

@ -43,6 +43,7 @@
/*#undef SDL_JOYSTICK_HIDAPI */
#else
#define SDL_JOYSTICK_HIDAPI 1
#define HAVE_LIBUSB 1
/* dynamically loaded libusb-1.0 dll: */
#define SDL_LIBUSB_DYNAMIC "usb100.dll"
#endif

View file

@ -80,9 +80,9 @@
# include <ctype.h>
#endif
#ifdef HAVE_MATH_H
# if defined(__WINRT__)
# if defined(_MSC_VER)
/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
for more information.
*/
# define _USE_MATH_DEFINES

View file

@ -142,7 +142,7 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn,
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
#else
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)SDL_endthread)
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
#endif
#elif defined(__OS2__)
@ -175,7 +175,7 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz
#undef SDL_CreateThread
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
#undef SDL_CreateThreadWithStackSize
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
#else
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)

View file

@ -59,7 +59,7 @@ typedef struct SDL_version
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 24
#define SDL_PATCHLEVEL 0
#define SDL_PATCHLEVEL 2
/**
* Macro to determine SDL version program was compiled against.

View file

@ -5,7 +5,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
else("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
else()
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()

View file

@ -5,7 +5,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
else("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
else()
set(SDL2_FOUND FALSE)
return()
endif()

View file

@ -39,54 +39,62 @@ unset(bindir)
unset(libdir)
unset(includedir)
set(_sdl2_libraries "@SDL_LIBS@")
set(_sdl2_static_private_libs "@SDL_STATIC_LIBS@")
set(_sdl2_libraries_in "@SDL_LIBS@")
set(_sdl2_static_private_libs_in "@SDL_STATIC_LIBS@")
# Convert _sdl2_libraries to list and keep only libraries
string(REGEX MATCHALL "-[lm]([-a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries}")
# Convert _sdl2_libraries to list and keep only libraries + library directories
string(REGEX MATCHALL "-[lm]([-a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries_in}")
string(REGEX REPLACE "^-l" "" _sdl2_libraries "${_sdl2_libraries}")
string(REGEX REPLACE ";-l" ";" _sdl2_libraries "${_sdl2_libraries}")
string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_libdirs "${_sdl2_libraries_in}")
string(REGEX REPLACE "^-L" "" _sdl2_libdirs "${_sdl2_libdirs}")
string(REGEX REPLACE ";-L" ";" _sdl2_libdirs "${_sdl2_libdirs}")
list(APPEND _sdl2_libdirs "${SDL2_LIBDIR}")
# Convert _sdl2_static_private_libs to list and keep only libraries
string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
# Convert _sdl2_static_private_libs to list and keep only libraries + library directories
string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)|(-pthread)" _sdl2_static_private_libs "${_sdl2_static_private_libs_in}")
string(REGEX REPLACE "^-l" "" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
string(REGEX REPLACE ";-l" ";" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_static_private_libdirs "${_sdl2_static_private_libs_in}")
string(REGEX REPLACE "^-L" "" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
if(_sdl2_libraries MATCHES ".*SDL2main.*")
list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
set(_sdl2main_library ${SDL2_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX})
if(EXISTS "${_sdl2main_library}")
set(SDL2MAIN_LIBRARY SDL2::SDL2main)
if(NOT TARGET SDL2::SDL2main)
add_library(SDL2::SDL2main STATIC IMPORTED)
set_target_properties(SDL2::SDL2main
PROPERTIES
IMPORTED_LOCATION "${_sdl2main_library}"
)
if(WIN32)
# INTERFACE_LINK_OPTIONS needs CMake 3.13
cmake_minimum_required(VERSION 3.13)
# Mark WinMain/WinMain@16 as undefined, such that it will be withheld by the linker.
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set_target_properties(SDL2::SDL2main
PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,--undefined=_WinMain@16"
)
else()
set_target_properties(SDL2::SDL2main
PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,--undefined=WinMain"
)
endif()
endif()
set(_sdl2main_library ${SDL2_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX})
if(EXISTS "${_sdl2main_library}")
set(SDL2MAIN_LIBRARY SDL2::SDL2main)
if(NOT TARGET SDL2::SDL2main)
add_library(SDL2::SDL2main STATIC IMPORTED)
set_target_properties(SDL2::SDL2main
PROPERTIES
IMPORTED_LOCATION "${_sdl2main_library}"
)
if(WIN32)
# INTERFACE_LINK_OPTIONS needs CMake 3.13
cmake_minimum_required(VERSION 3.13)
# Mark WinMain/WinMain@16 as undefined, such that it will be withheld by the linker.
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set_target_properties(SDL2::SDL2main
PROPERTIES
INTERFACE_LINK_OPTIONS "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>"
)
else()
set_target_properties(SDL2::SDL2main
PROPERTIES
INTERFACE_LINK_OPTIONS "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>"
)
endif()
endif()
set(SDL2_SDL2main_FOUND TRUE)
else()
set(SDL2_SDL2main_FOUND FALSE)
endif()
unset(_sdl2main_library)
set(SDL2_SDL2main_FOUND TRUE)
else()
set(SDL2_SDL2main_FOUND FALSE)
endif()
unset(_sdl2main_library)
# Remove SDL2 since this is the "central" library
# Remove SDL2main since this will be provided by SDL2::SDL2main (if available)
@ -103,6 +111,7 @@ if(WIN32)
set_target_properties(SDL2::SDL2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries}"
INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_IMPLIB "${_sdl2_implib}"
IMPORTED_LOCATION "${_sdl2_dll}"
@ -122,6 +131,7 @@ else()
set_target_properties(SDL2::SDL2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries}"
INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${_sdl2_shared}"
)
@ -142,6 +152,7 @@ if(EXISTS "${_sdl2_static}")
IMPORTED_LOCATION "${_sdl2_static}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries};${_sdl2_static_private_libs}"
INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs};${_sdl2_static_private_libdirs}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
)
endif()
@ -159,7 +170,7 @@ if(EXISTS "${_sdl2test_library}")
add_library(SDL2::SDL2test STATIC IMPORTED)
set_target_properties(SDL2::SDL2test
PROPERTIES
IMPORTED_LOCATION "_sdl2test_library"
IMPORTED_LOCATION "${_sdl2test_library}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
)

View file

@ -70,8 +70,8 @@ AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework])
sdl_framework=$SDL2_FRAMEWORK
else
for d in / ~/ /System/; do
if test -d "$dLibrary/Frameworks/SDL2.framework"; then
sdl_framework="$dLibrary/Frameworks/SDL2.framework"
if test -d "${d}Library/Frameworks/SDL2.framework"; then
sdl_framework="${d}Library/Frameworks/SDL2.framework"
fi
done
fi

View file

@ -247,7 +247,7 @@ SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
*(dst++) = outsample;
}
outtime += outtimeincr;
outtime = outtimeincr * i;
}
return outframes * chans * sizeof (float);

View file

@ -54,7 +54,6 @@ struct SDL_PrivateAudioData
AudioStreamBasicDescription strdesc;
SDL_sem *ready_semaphore;
char *thread_error;
SDL_atomic_t shutdown;
#if MACOSX_COREAUDIO
AudioDeviceID deviceID;
SDL_atomic_t device_change_flag;

View file

@ -523,9 +523,16 @@ outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe
{
SDL_AudioDevice *this = (SDL_AudioDevice *) inUserData;
/* This flag is set before this->mixer_lock is destroyed during
shutdown, so check it before grabbing the mutex, and then check it
again _after_ in case we blocked waiting on the lock. */
if (SDL_AtomicGet(&this->shutdown)) {
return; /* don't do anything, since we don't even want to enqueue this buffer again. */
}
SDL_LockMutex(this->mixer_lock);
if (SDL_AtomicGet(&this->hidden->shutdown)) {
if (SDL_AtomicGet(&this->shutdown)) {
SDL_UnlockMutex(this->mixer_lock);
return; /* don't do anything, since we don't even want to enqueue this buffer again. */
}
@ -694,6 +701,19 @@ COREAUDIO_CloseDevice(_THIS)
}
#endif
/* if callback fires again, feed silence; don't call into the app. */
SDL_AtomicSet(&this->paused, 1);
/* dispose of the audio queue before waiting on the thread, or it might stall for a long time! */
if (this->hidden->audioQueue) {
AudioQueueDispose(this->hidden->audioQueue, 0);
}
if (this->hidden->thread) {
SDL_assert(SDL_AtomicGet(&this->shutdown) != 0); /* should have been set by SDL_audio.c */
SDL_WaitThread(this->hidden->thread, NULL);
}
if (iscapture) {
open_capture_devices--;
} else {
@ -718,18 +738,6 @@ COREAUDIO_CloseDevice(_THIS)
open_devices = NULL;
}
/* if callback fires again, feed silence; don't call into the app. */
SDL_AtomicSet(&this->paused, 1);
if (this->hidden->audioQueue) {
AudioQueueDispose(this->hidden->audioQueue, 1);
}
if (this->hidden->thread) {
SDL_AtomicSet(&this->hidden->shutdown, 1);
SDL_WaitThread(this->hidden->thread, NULL);
}
if (this->hidden->ready_semaphore) {
SDL_DestroySemaphore(this->hidden->ready_semaphore);
}
@ -973,7 +981,7 @@ audioqueue_thread(void *arg)
/* init was successful, alert parent thread and start running... */
SDL_SemPost(this->hidden->ready_semaphore);
while (!SDL_AtomicGet(&this->hidden->shutdown)) {
while (!SDL_AtomicGet(&this->shutdown)) {
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1);
#if MACOSX_COREAUDIO
@ -1123,7 +1131,6 @@ COREAUDIO_OpenDevice(_THIS, const char *devname)
#endif
/* This has to init in a new thread so it can get its own CFRunLoop. :/ */
SDL_AtomicSet(&this->hidden->shutdown, 0);
this->hidden->ready_semaphore = SDL_CreateSemaphore(0);
if (!this->hidden->ready_semaphore) {
return -1; /* oh well. */

View file

@ -477,7 +477,7 @@ PAUDIO_Init(SDL_AudioDriverImpl * impl)
/* Set the function pointers */
impl->OpenDevice = PAUDIO_OpenDevice;
impl->PlayDevice = PAUDIO_PlayDevice;
impl->PlayDevice = PAUDIO_WaitDevice;
impl->WaitDevice = PAUDIO_WaitDevice;
impl->GetDeviceBuf = PAUDIO_GetDeviceBuf;
impl->CloseDevice = PAUDIO_CloseDevice;
impl->OnlyHasDefaultOutputDevice = SDL_TRUE; /* !!! FIXME: add device enum! */

View file

@ -544,6 +544,10 @@ SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
SDL_UDEV_CallbackList *item;
SDL_UDEV_CallbackList *prev = NULL;
if (_this == NULL) {
return;
}
for (item = _this->first; item != NULL; item = item->next) {
/* found it, remove it. */
if (item->callback == cb) {

View file

@ -25,8 +25,12 @@
#define _INCLUDED_WINDOWS_H
#if defined(__WIN32__)
#define WIN32_LEAN_AND_MEAN
#define STRICT
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#ifndef STRICT
#define STRICT 1
#endif
#ifndef UNICODE
#define UNICODE 1
#endif
@ -40,9 +44,14 @@
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
#endif
#define WINVER _WIN32_WINNT
#elif defined(__WINGDK__)
#define WIN32_LEAN_AND_MEAN
#define STRICT
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#ifndef STRICT
#define STRICT 1
#endif
#ifndef UNICODE
#define UNICODE 1
#endif
@ -50,12 +59,13 @@
#undef _WIN32_WINNT
#define _WIN32_WINNT 0xA00
#define WINVER _WIN32_WINNT
#elif defined(__XBOXONE__) || defined(__XBOXSERIES__)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#ifndef STRICT
#define STRICT
#define STRICT 1
#endif
#ifndef UNICODE
#define UNICODE 1

View file

@ -947,7 +947,7 @@ SDL_SendEditingText(const char *text, int start, int length)
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE) &&
SDL_strlen(text) > SDL_arraysize(event.text.text)) {
SDL_strlen(text) >= SDL_arraysize(event.text.text)) {
event.editExt.type = SDL_TEXTEDITING_EXT;
event.editExt.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.editExt.text = text ? SDL_strdup(text) : NULL;

View file

@ -681,7 +681,7 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL;
#endif /* HAVE_DRIVER_BACKEND */
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
/* libusb HIDAPI Implementation */
/* Include this now, for our dynamically-loaded libusb context */
@ -737,6 +737,7 @@ static struct
);
int (LIBUSB_CALL *handle_events)(libusb_context *ctx);
int (LIBUSB_CALL *handle_events_completed)(libusb_context *ctx, int *completed);
const char * (LIBUSB_CALL *error_name)(int errcode);
} libusb_ctx;
#define libusb_init libusb_ctx.init
@ -765,6 +766,7 @@ static struct
#define libusb_interrupt_transfer libusb_ctx.interrupt_transfer
#define libusb_handle_events libusb_ctx.handle_events
#define libusb_handle_events_completed libusb_ctx.handle_events_completed
#define libusb_error_name libusb_ctx.error_name
#define hid_device LIBUSB_hid_device
#define hid_device_ LIBUSB_hid_device_
@ -816,6 +818,34 @@ SDL_libusb_get_string_descriptor(libusb_device_handle *dev,
#undef HIDAPI_H__
#include "libusb/hid.c"
#undef libusb_init
#undef libusb_exit
#undef libusb_get_device_list
#undef libusb_free_device_list
#undef libusb_get_device_descriptor
#undef libusb_get_active_config_descriptor
#undef libusb_get_config_descriptor
#undef libusb_free_config_descriptor
#undef libusb_get_bus_number
#undef libusb_get_device_address
#undef libusb_open
#undef libusb_close
#undef libusb_claim_interface
#undef libusb_release_interface
#undef libusb_kernel_driver_active
#undef libusb_detach_kernel_driver
#undef libusb_attach_kernel_driver
#undef libusb_set_interface_alt_setting
#undef libusb_alloc_transfer
#undef libusb_submit_transfer
#undef libusb_cancel_transfer
#undef libusb_free_transfer
#undef libusb_control_transfer
#undef libusb_interrupt_transfer
#undef libusb_handle_events
#undef libusb_handle_events_completed
#undef libusb_error_name
#undef hid_device
#undef hid_device_
#undef hid_init
@ -843,7 +873,7 @@ SDL_libusb_get_string_descriptor(libusb_device_handle *dev,
#undef make_path
#undef read_thread
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
#endif /* !SDL_HIDAPI_DISABLED */
@ -898,7 +928,7 @@ static const struct hidapi_backend DRIVER_Backend = {
};
#endif /* HAVE_DRIVER_BACKEND */
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
static const struct hidapi_backend LIBUSB_Backend = {
(void*)LIBUSB_hid_write,
(void*)LIBUSB_hid_read_timeout,
@ -913,7 +943,7 @@ static const struct hidapi_backend LIBUSB_Backend = {
(void*)LIBUSB_hid_get_indexed_string,
(void*)LIBUSB_hid_error
};
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
struct SDL_hid_device_
{
@ -923,7 +953,7 @@ struct SDL_hid_device_
};
static char device_magic;
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC)
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
static SDL_hid_device *
CreateHIDDeviceWrapper(void *device, const struct hidapi_backend *backend)
@ -935,7 +965,7 @@ CreateHIDDeviceWrapper(void *device, const struct hidapi_backend *backend)
return wrapper;
}
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */
static void
DeleteHIDDeviceWrapper(SDL_hid_device *device)
@ -951,7 +981,7 @@ DeleteHIDDeviceWrapper(SDL_hid_device *device)
}
#if !SDL_HIDAPI_DISABLED
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC)
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
#define COPY_IF_EXISTS(var) \
if (pSrc->var != NULL) { \
@ -988,7 +1018,7 @@ CopyHIDDeviceInfo(struct SDL_hid_device_info *pSrc, struct SDL_hid_device_info *
#undef COPY_IF_EXISTS
#undef WCOPY_IF_EXISTS
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */
#endif /* !SDL_HIDAPI_DISABLED */
static int SDL_hidapi_refcount = 0;
@ -1033,23 +1063,27 @@ int SDL_hid_init(void)
}
#endif
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
if (SDL_getenv("SDL_HIDAPI_DISABLE_LIBUSB") != NULL) {
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
"libusb disabled by SDL_HIDAPI_DISABLE_LIBUSB");
libusb_ctx.libhandle = NULL;
} else {
++attempts;
#ifdef SDL_LIBUSB_DYNAMIC
libusb_ctx.libhandle = SDL_LoadObject(SDL_LIBUSB_DYNAMIC);
#else
libusb_ctx.libhandle = (void *)1;
#endif
if (libusb_ctx.libhandle != NULL) {
SDL_bool loaded = SDL_TRUE;
#ifdef __OS2__
#define LOAD_LIBUSB_SYMBOL(func) \
if (!(libusb_ctx.func = SDL_LoadFunction(libusb_ctx.libhandle,"_libusb_" #func))) {loaded = SDL_FALSE;}
#else
#ifdef SDL_LIBUSB_DYNAMIC
#define LOAD_LIBUSB_SYMBOL(func) \
if (!(libusb_ctx.func = SDL_LoadFunction(libusb_ctx.libhandle, "libusb_" #func))) {loaded = SDL_FALSE;}
#endif
#else
#define LOAD_LIBUSB_SYMBOL(func) \
libusb_ctx.func = libusb_##func;
#endif
LOAD_LIBUSB_SYMBOL(init)
LOAD_LIBUSB_SYMBOL(exit)
LOAD_LIBUSB_SYMBOL(get_device_list)
@ -1076,21 +1110,26 @@ int SDL_hid_init(void)
LOAD_LIBUSB_SYMBOL(interrupt_transfer)
LOAD_LIBUSB_SYMBOL(handle_events)
LOAD_LIBUSB_SYMBOL(handle_events_completed)
LOAD_LIBUSB_SYMBOL(error_name)
#undef LOAD_LIBUSB_SYMBOL
if (!loaded) {
#ifdef SDL_LIBUSB_DYNAMIC
SDL_UnloadObject(libusb_ctx.libhandle);
#endif
libusb_ctx.libhandle = NULL;
/* SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, SDL_LIBUSB_DYNAMIC " found but could not load function"); */
} else if (LIBUSB_hid_init() < 0) {
#ifdef SDL_LIBUSB_DYNAMIC
SDL_UnloadObject(libusb_ctx.libhandle);
#endif
libusb_ctx.libhandle = NULL;
} else {
++success;
}
}
}
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
#if HAVE_PLATFORM_BACKEND
++attempts;
@ -1136,13 +1175,15 @@ int SDL_hid_exit(void)
#endif /* __LINUX __ */
#endif /* HAVE_PLATFORM_BACKEND */
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
if (libusb_ctx.libhandle) {
result |= LIBUSB_hid_exit();
#ifdef SDL_LIBUSB_DYNAMIC
SDL_UnloadObject(libusb_ctx.libhandle);
#endif
libusb_ctx.libhandle = NULL;
}
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
return result;
}
@ -1171,8 +1212,8 @@ Uint32 SDL_hid_device_change_count(void)
struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id)
{
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC)
#ifdef SDL_LIBUSB_DYNAMIC
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
#ifdef HAVE_LIBUSB
struct SDL_hid_device_info *usb_devs = NULL;
struct SDL_hid_device_info *usb_dev;
#endif
@ -1190,7 +1231,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
return NULL;
}
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
if (libusb_ctx.libhandle) {
usb_devs = LIBUSB_hid_enumerate(vendor_id, product_id);
#ifdef DEBUG_HIDAPI
@ -1219,7 +1260,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
last = new_dev;
}
}
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
#ifdef HAVE_DRIVER_BACKEND
driver_devs = DRIVER_hid_enumerate(vendor_id, product_id);
@ -1249,7 +1290,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
raw_dev->manufacturer_string, raw_dev->product_string,
raw_dev->vendor_id, raw_dev->product_id);
#endif
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
for (usb_dev = usb_devs; usb_dev; usb_dev = usb_dev->next) {
if (raw_dev->vendor_id == usb_dev->vendor_id &&
raw_dev->product_id == usb_dev->product_id &&
@ -1272,7 +1313,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
if (!bFound) {
new_dev = (struct SDL_hid_device_info*) SDL_malloc(sizeof(struct SDL_hid_device_info));
if (!new_dev) {
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
if (libusb_ctx.libhandle) {
LIBUSB_hid_free_enumeration(usb_devs);
}
@ -1297,7 +1338,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
}
#endif /* HAVE_PLATFORM_BACKEND */
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
if (libusb_ctx.libhandle) {
LIBUSB_hid_free_enumeration(usb_devs);
}
@ -1306,7 +1347,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
#else
return NULL;
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */
}
void SDL_hid_free_enumeration(struct SDL_hid_device_info *devs)
@ -1324,7 +1365,7 @@ void SDL_hid_free_enumeration(struct SDL_hid_device_info *devs)
SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
{
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC)
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
void *pDevice = NULL;
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
@ -1344,21 +1385,21 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
}
#endif /* HAVE_DRIVER_BACKEND */
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
if (libusb_ctx.libhandle &&
(pDevice = LIBUSB_hid_open(vendor_id, product_id, serial_number)) != NULL) {
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
}
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */
return NULL;
}
SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */)
{
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC)
#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
void *pDevice = NULL;
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
@ -1378,14 +1419,14 @@ SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */
}
#endif /* HAVE_DRIVER_BACKEND */
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
if (libusb_ctx.libhandle &&
(pDevice = LIBUSB_hid_open_path(path, bExclusive)) != NULL) {
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
}
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || HAVE_LIBUSB */
return NULL;
}
@ -1539,7 +1580,7 @@ void SDL_hid_ble_scan(SDL_bool active)
/* This is needed to enable input for Nyko and EVORETRO GameCube adaptors */
void SDL_EnableGameCubeAdaptors(void)
{
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
libusb_context *context = NULL;
libusb_device **devs = NULL;
libusb_device_handle *handle = NULL;
@ -1551,10 +1592,10 @@ void SDL_EnableGameCubeAdaptors(void)
return;
}
if (libusb_init(&context) == 0) {
num_devs = libusb_get_device_list(context, &devs);
if (libusb_ctx.init(&context) == 0) {
num_devs = libusb_ctx.get_device_list(context, &devs);
for (i = 0; i < num_devs; ++i) {
if (libusb_get_device_descriptor(devs[i], &desc) != 0) {
if (libusb_ctx.get_device_descriptor(devs[i], &desc) != 0) {
continue;
}
@ -1562,33 +1603,33 @@ void SDL_EnableGameCubeAdaptors(void)
continue;
}
if (libusb_open(devs[i], &handle) != 0) {
if (libusb_ctx.open(devs[i], &handle) != 0) {
continue;
}
if (libusb_kernel_driver_active(handle, 0)) {
if (libusb_detach_kernel_driver(handle, 0) == 0) {
if (libusb_ctx.kernel_driver_active(handle, 0)) {
if (libusb_ctx.detach_kernel_driver(handle, 0) == 0) {
kernel_detached = 1;
}
}
if (libusb_claim_interface(handle, 0) == 0) {
libusb_control_transfer(handle, 0x21, 11, 0x0001, 0, NULL, 0, 1000);
libusb_release_interface(handle, 0);
if (libusb_ctx.claim_interface(handle, 0) == 0) {
libusb_ctx.control_transfer(handle, 0x21, 11, 0x0001, 0, NULL, 0, 1000);
libusb_ctx.release_interface(handle, 0);
}
if (kernel_detached) {
libusb_attach_kernel_driver(handle, 0);
libusb_ctx.attach_kernel_driver(handle, 0);
}
libusb_close(handle);
libusb_ctx.close(handle);
}
libusb_free_device_list(devs, 1);
libusb_ctx.free_device_list(devs, 1);
libusb_exit(context);
libusb_ctx.exit(context);
}
#endif /* SDL_LIBUSB_DYNAMIC */
#endif /* HAVE_LIBUSB */
}
#endif /* HAVE_ENABLE_GAMECUBE_ADAPTORS */

View file

@ -22,7 +22,7 @@
#ifdef SDL_JOYSTICK_HIDAPI
#ifdef SDL_LIBUSB_DYNAMIC
#ifdef HAVE_LIBUSB
#define HAVE_ENABLE_GAMECUBE_ADAPTORS
#endif

View file

@ -1016,6 +1016,7 @@ static void LIBUSB_CALL read_callback(struct libusb_transfer *transfer)
static int SDLCALL read_thread(void *param)
{
int res;
hid_device *dev = (hid_device *)param;
uint8_t *buf;
const size_t length = dev->input_ep_max_packet_size;
@ -1034,14 +1035,18 @@ static int SDLCALL read_thread(void *param)
/* Make the first submission. Further submissions are made
from inside read_callback() */
libusb_submit_transfer(dev->transfer);
res = libusb_submit_transfer(dev->transfer);
if(res < 0) {
LOG("libusb_submit_transfer failed: %d %s. Stopping read_thread from running\n", res, libusb_error_name(res));
dev->shutdown_thread = 1;
dev->transfer_loop_finished = 1;
}
/* Notify the main thread that the read thread is up and running. */
SDL_WaitThreadBarrier(&dev->barrier);
/* Handle all the events. */
while (!dev->shutdown_thread) {
int res;
res = libusb_handle_events(usb_context);
if (res < 0) {
/* There was an error. */

View file

@ -811,6 +811,8 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive)
process_pending_events();
device_set = IOHIDManagerCopyDevices(hid_mgr);
if (!device_set)
return NULL;
num_devices = CFSetGetCount(device_set);
device_array = (IOHIDDeviceRef *)calloc(num_devices, sizeof(IOHIDDeviceRef));

View file

@ -874,6 +874,11 @@ RAWINPUT_JoystickInit(void)
SDL_assert(!SDL_RAWINPUT_inited);
if (!WIN_IsWindowsVistaOrGreater()) {
/* According to bug 6400, this doesn't work on Windows XP */
return -1;
}
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT, SDL_TRUE)) {
return -1;
}

View file

@ -60,12 +60,12 @@ SDL_LoadFunction(void *handle, const char *name)
{
void *symbol = dlsym(handle, name);
if (symbol == NULL) {
/* append an underscore for platforms that need that. */
/* prepend an underscore for platforms that need that. */
SDL_bool isstack;
size_t len = 1 + SDL_strlen(name) + 1;
char *_name = SDL_small_alloc(char, len, &isstack);
size_t len = SDL_strlen(name) + 1;
char *_name = SDL_small_alloc(char, len + 1, &isstack);
_name[0] = '_';
SDL_strlcpy(&_name[1], name, len);
SDL_memcpy(&_name[1], name, len);
symbol = dlsym(handle, _name);
SDL_small_free(_name, isstack);
if (symbol == NULL) {

View file

@ -47,11 +47,20 @@ SDL_LoadObject(const char *sofile)
pszModName = OS2_UTF8ToSys(sofile);
ulRC = DosLoadModule(acError, sizeof(acError), pszModName, &hModule);
SDL_free(pszModName);
if (ulRC != NO_ERROR) {
SDL_SetError("Failed loading %s (E%u)", acError, ulRC);
return NULL;
if (ulRC != NO_ERROR && !SDL_strrchr(pszModName, '\\') && !SDL_strrchr(pszModName, '/')) {
/* strip .dll extension and retry only if name has no path. */
size_t len = SDL_strlen(pszModName);
if (len > 4 && SDL_strcasecmp(&pszModName[len - 4], ".dll") == 0) {
pszModName[len - 4] = '\0';
ulRC = DosLoadModule(acError, sizeof(acError), pszModName, &hModule);
}
}
if (ulRC != NO_ERROR) {
SDL_SetError("Failed loading %s: %s (E%u)", sofile, acError, ulRC);
hModule = NULLHANDLE;
}
SDL_free(pszModName);
return (void *)hModule;
}
@ -63,6 +72,16 @@ SDL_LoadFunction(void *handle, const char *name)
PFN pFN;
ulRC = DosQueryProcAddr((HMODULE)handle, 0, name, &pFN);
if (ulRC != NO_ERROR) {
/* retry with an underscore prepended, e.g. for gcc-built dlls. */
SDL_bool isstack;
size_t len = SDL_strlen(name) + 1;
char *_name = SDL_small_alloc(char, len + 1, &isstack);
_name[0] = '_';
SDL_memcpy(&_name[1], name, len);
ulRC = DosQueryProcAddr((HMODULE)handle, 0, _name, &pFN);
SDL_small_free(_name, isstack);
}
if (ulRC != NO_ERROR) {
SDL_SetError("Failed loading procedure %s (E%u)", name, ulRC);
return NULL;

View file

@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,24,0,0
PRODUCTVERSION 2,24,0,0
FILEVERSION 2,24,2,0
PRODUCTVERSION 2,24,2,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 24, 0, 0\0"
VALUE "FileVersion", "2, 24, 2, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2022 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "2, 24, 0, 0\0"
VALUE "ProductVersion", "2, 24, 2, 0\0"
END
END
BLOCK "VarFileInfo"

View file

@ -173,6 +173,7 @@ typedef struct
ID3D12CommandQueue *commandQueue;
ID3D12GraphicsCommandList2 *commandList;
DXGI_SWAP_EFFECT swapEffect;
UINT swapFlags;
/* Descriptor heaps */
ID3D12DescriptorHeap* rtvDescriptorHeap;
@ -352,9 +353,11 @@ D3D12_ReleaseAll(SDL_Renderer * renderer)
for (i = 0; i < SDL_D3D12_NUM_VERTEX_BUFFERS; ++i) {
SAFE_RELEASE(data->vertexBuffers[i].resource);
data->vertexBuffers[i].size = 0;
}
data->swapEffect = (DXGI_SWAP_EFFECT) 0;
data->swapFlags = 0;
data->currentRenderTargetView.ptr = 0;
data->currentSampler.ptr = 0;
@ -719,6 +722,13 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
typedef HRESULT(WINAPI* PFN_CREATE_DXGI_FACTORY)(UINT flags, REFIID riid, void** ppFactory);
PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc;
PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc;
#endif
#ifndef __GDK__
HMODULE kernel32;
typedef HANDLE(WINAPI* PFN_CREATE_EVENT_EX)(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCWSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess);
PFN_CREATE_EVENT_EX CreateEventExFunc;
#else
#define CreateEventExFunc CreateEventEx
#endif
D3D12_RenderData* data = (D3D12_RenderData*)renderer->driverdata;
ID3D12Device* d3dDevice = NULL;
@ -748,6 +758,21 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
/* See if we need debug interfaces */
createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE);
#ifndef __GDK__
/* CreateEventEx() arrived in Vista, so we need to load it with GetProcAddress for XP. */
kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if (!kernel32) {
result = E_FAIL;
goto done;
}
CreateEventExFunc = (PFN_CREATE_EVENT_EX) GetProcAddress(kernel32, "CreateEventExW");
if (!CreateEventExFunc) {
result = E_FAIL;
goto done;
}
#endif
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
data->hDXGIMod = SDL_LoadObject("dxgi.dll");
if (!data->hDXGIMod) {
@ -999,7 +1024,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
data->fenceValue++;
data->fenceEvent = CreateEventEx(NULL, NULL, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
data->fenceEvent = CreateEventExFunc(NULL, NULL, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
if (!data->fenceEvent) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateEventEx"), result);
goto done;
@ -1210,6 +1235,7 @@ D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
}
data->swapEffect = swapChainDesc.SwapEffect;
data->swapFlags = swapChainDesc.Flags;
done:
SAFE_RELEASE(swapChain);
@ -1260,10 +1286,15 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
D3D12_RENDER_TARGET_VIEW_DESC rtvDesc;
D3D12_CPU_DESCRIPTOR_HANDLE rtvDescriptor;
/* Release resources in the current command list */
D3D12_IssueBatch(data);
D3D_CALL(data->commandList, OMSetRenderTargets, 0, NULL, FALSE, NULL);
/* Release render targets */
for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) {
SAFE_RELEASE(data->renderTargets[i]);
}
/* The width and height of the swap chain must be based on the display's
* non-rotated size.
*/
@ -1282,7 +1313,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
0,
w, h,
DXGI_FORMAT_UNKNOWN,
0
data->swapFlags
);
if (result == DXGI_ERROR_DEVICE_REMOVED) {
/* If the device was removed for any reason, a new device and swap chain will need to be created. */

View file

@ -169,6 +169,7 @@ typedef struct GLES2_RenderData
#endif
GLES2_DrawStateCache drawstate;
GLES2_ShaderIncludeType texcoord_precision_hint;
} GLES2_RenderData;
#define GLES2_MAX_CACHED_PROGRAMS 8
@ -492,20 +493,56 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment)
static GLuint
GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_type)
{
GLuint id;
GLuint id = 0;
GLint compileSuccessful = GL_FALSE;
const char *shader_src = (char *)GLES2_GetShader(type);
int attempt, num_src;
const GLchar *shader_src_list[3];
const GLchar *shader_body = GLES2_GetShader(type);
if (!shader_src) {
SDL_SetError("No shader src");
if (!shader_body) {
SDL_SetError("No shader body src");
return 0;
}
/* Compile */
id = data->glCreateShader(shader_type);
data->glShaderSource(id, 1, &shader_src, NULL);
data->glCompileShader(id);
data->glGetShaderiv(id, GL_COMPILE_STATUS, &compileSuccessful);
for (attempt = 0; attempt < 2 && !compileSuccessful; ++attempt) {
num_src = 0;
shader_src_list[num_src++] = GLES2_GetShaderPrologue(type);
if (shader_type == GL_FRAGMENT_SHADER) {
if (attempt == 0) {
shader_src_list[num_src++] = GLES2_GetShaderInclude(data->texcoord_precision_hint);
} else {
shader_src_list[num_src++] = GLES2_GetShaderInclude(GLES2_SHADER_FRAGMENT_INCLUDE_UNDEF_PRECISION);
}
}
shader_src_list[num_src++] = shader_body;
SDL_assert(num_src <= SDL_arraysize(shader_src_list));
#ifdef DEBUG_PRINT_SHADERS
{
int i;
char *message = NULL;
SDL_asprintf(&message, "Compiling shader:\n");
for (i = 0; i < num_src; ++i) {
char *last_message = message;
SDL_asprintf(&message, "%s%s", last_message, shader_src_list[i]);
SDL_free(last_message);
}
SDL_Log("%s\n", message);
SDL_free(message);
}
#endif
/* Compile */
id = data->glCreateShader(shader_type);
data->glShaderSource(id, num_src, shader_src_list, NULL);
data->glCompileShader(id);
data->glGetShaderiv(id, GL_COMPILE_STATUS, &compileSuccessful);
}
if (!compileSuccessful) {
SDL_bool isstack = SDL_FALSE;
@ -520,10 +557,10 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_t
}
}
if (info) {
SDL_SetError("Failed to load the shader: %s", info);
SDL_SetError("Failed to load the shader %d: %s", type, info);
SDL_small_free(info, isstack);
} else {
SDL_SetError("Failed to load the shader");
SDL_SetError("Failed to load the shader %d", type);
}
data->glDeleteShader(id);
return 0;
@ -535,6 +572,27 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_t
return id;
}
static int GLES2_CacheShaders(GLES2_RenderData * data)
{
int shader;
data->texcoord_precision_hint = GLES2_GetTexCoordPrecisionEnumFromHint();
for (shader = 0; shader < GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES; ++shader) {
GLenum shader_type;
if (shader == GLES2_SHADER_VERTEX_DEFAULT) {
shader_type = GL_VERTEX_SHADER;
} else {
shader_type = GL_FRAGMENT_SHADER;
}
if (!GLES2_CacheShader(data, (GLES2_ShaderType) shader, shader_type)) {
return -1;
}
}
return 0;
}
static int
GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int h)
{
@ -2071,6 +2129,13 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
goto error;
}
if (GLES2_CacheShaders(data) < 0) {
SDL_GL_DeleteContext(data->context);
SDL_free(renderer);
SDL_free(data);
goto error;
}
#if __WINRT__
/* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync
* is turned on. Not doing so will freeze the screen's contents to that
@ -2144,7 +2209,9 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21;
#endif
#ifdef GL_TEXTURE_EXTERNAL_OES
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_EXTERNAL_OES;
if (GLES2_CacheShader(data, GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES, GL_FRAGMENT_SHADER)) {
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_EXTERNAL_OES;
}
#endif
/* Set up parameters for rendering */

View file

@ -22,125 +22,132 @@
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
#include "SDL_hints.h"
#include "SDL_video.h"
#include "SDL_opengles2.h"
#include "SDL_shaders_gles2.h"
#include "SDL_stdinc.h"
#define SHADER_PRELOGUE "\n\
#if GL_FRAGMENT_PRECISION_HIGH\n\
precision mediump float;\n\
#else\n\
#define mediump\n\
#define highp\n\
#define lowp\n\
#endif\n\
"
/*************************************************************************************************
* Vertex/fragment shader source *
*************************************************************************************************/
static const Uint8 GLES2_Vertex_Default[] = " \
uniform mat4 u_projection; \
attribute vec2 a_position; \
attribute vec4 a_color; \
attribute vec2 a_texCoord; \
varying vec2 v_texCoord; \
varying vec4 v_color; \
\
void main() \
{ \
v_texCoord = a_texCoord; \
gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\
gl_PointSize = 1.0; \
v_color = a_color; \
} \
";
static const Uint8 GLES2_Fragment_Solid[] = SHADER_PRELOGUE" \
varying vec4 v_color; \
\
void main() \
{ \
gl_FragColor = v_color; \
} \
";
static const char GLES2_Fragment_Include_Best_Texture_Precision[] = \
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n" \
"#define SDL_TEXCOORD_PRECISION highp\n" \
"#else\n" \
"#define SDL_TEXCOORD_PRECISION mediump\n" \
"#endif\n" \
"\n" \
"precision mediump float;\n" \
"\n" \
;
static const Uint8 GLES2_Fragment_TextureABGR[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
varying highp vec2 v_texCoord;\n\
#else\n\
varying vec2 v_texCoord;\n\
#endif\n\
\
void main() \
{ \
gl_FragColor = texture2D(u_texture, v_texCoord); \
gl_FragColor *= v_color; \
} \
";
static const char GLES2_Fragment_Include_Medium_Texture_Precision[] = \
"#define SDL_TEXCOORD_PRECISION mediump\n" \
"precision mediump float;\n" \
"\n" \
;
static const char GLES2_Fragment_Include_High_Texture_Precision[] = \
"#define SDL_TEXCOORD_PRECISION highp\n" \
"precision mediump float;\n" \
"\n" \
;
static const char GLES2_Fragment_Include_Undef_Precision[] = \
"#define mediump\n" \
"#define highp\n" \
"#define lowp\n" \
"#define SDL_TEXCOORD_PRECISION\n" \
"\n" \
;
static const char GLES2_Vertex_Default[] = \
"uniform mat4 u_projection;\n" \
"attribute vec2 a_position;\n" \
"attribute vec4 a_color;\n" \
"attribute vec2 a_texCoord;\n" \
"varying vec2 v_texCoord;\n" \
"varying vec4 v_color;\n" \
"\n" \
"void main()\n" \
"{\n" \
" v_texCoord = a_texCoord;\n" \
" gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\n" \
" gl_PointSize = 1.0;\n" \
" v_color = a_color;\n" \
"}\n" \
;
static const char GLES2_Fragment_Solid[] = \
"varying mediump vec4 v_color;\n" \
"\n" \
"void main()\n" \
"{\n" \
" gl_FragColor = v_color;\n" \
"}\n" \
;
static const char GLES2_Fragment_TextureABGR[] = \
"uniform sampler2D u_texture;\n" \
"varying mediump vec4 v_color;\n" \
"varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;\n" \
"\n" \
"void main()\n" \
"{\n" \
" gl_FragColor = texture2D(u_texture, v_texCoord);\n" \
" gl_FragColor *= v_color;\n" \
"}\n" \
;
/* ARGB to ABGR conversion */
static const Uint8 GLES2_Fragment_TextureARGB[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
varying highp vec2 v_texCoord;\n\
#else\n\
varying vec2 v_texCoord;\n\
#endif\n\
\
void main() \
{ \
vec4 abgr = texture2D(u_texture, v_texCoord); \
gl_FragColor = abgr; \
gl_FragColor.r = abgr.b; \
gl_FragColor.b = abgr.r; \
gl_FragColor *= v_color; \
} \
";
static const char GLES2_Fragment_TextureARGB[] = \
"uniform sampler2D u_texture;\n" \
"varying mediump vec4 v_color;\n" \
"varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;\n" \
"\n" \
"void main()\n" \
"{\n" \
" mediump vec4 abgr = texture2D(u_texture, v_texCoord);\n" \
" gl_FragColor = abgr;\n" \
" gl_FragColor.r = abgr.b;\n" \
" gl_FragColor.b = abgr.r;\n" \
" gl_FragColor *= v_color;\n" \
"}\n" \
;
/* RGB to ABGR conversion */
static const Uint8 GLES2_Fragment_TextureRGB[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
varying highp vec2 v_texCoord;\n\
#else\n\
varying vec2 v_texCoord;\n\
#endif\n\
\
void main() \
{ \
vec4 abgr = texture2D(u_texture, v_texCoord); \
gl_FragColor = abgr; \
gl_FragColor.r = abgr.b; \
gl_FragColor.b = abgr.r; \
gl_FragColor.a = 1.0; \
gl_FragColor *= v_color; \
} \
";
static const char GLES2_Fragment_TextureRGB[] = \
"uniform sampler2D u_texture;\n" \
"varying mediump vec4 v_color;\n" \
"varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;\n" \
"\n" \
"void main()\n" \
"{\n" \
" mediump vec4 abgr = texture2D(u_texture, v_texCoord);\n" \
" gl_FragColor = abgr;\n" \
" gl_FragColor.r = abgr.b;\n" \
" gl_FragColor.b = abgr.r;\n" \
" gl_FragColor.a = 1.0;\n" \
" gl_FragColor *= v_color;\n" \
"}\n" \
;
/* BGR to ABGR conversion */
static const Uint8 GLES2_Fragment_TextureBGR[] = SHADER_PRELOGUE" \
uniform sampler2D u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
varying highp vec2 v_texCoord;\n\
#else\n\
varying vec2 v_texCoord;\n\
#endif\n\
\
void main() \
{ \
vec4 abgr = texture2D(u_texture, v_texCoord); \
gl_FragColor = abgr; \
gl_FragColor.a = 1.0; \
gl_FragColor *= v_color; \
} \
";
static const char GLES2_Fragment_TextureBGR[] = \
"uniform sampler2D u_texture;\n" \
"varying mediump vec4 v_color;\n" \
"varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;\n" \
"\n" \
"void main()\n" \
"{\n" \
" mediump vec4 abgr = texture2D(u_texture, v_texCoord);\n" \
" gl_FragColor = abgr;\n" \
" gl_FragColor.a = 1.0;\n" \
" gl_FragColor *= v_color;\n" \
"}\n" \
;
#if SDL_HAVE_YUV
@ -152,6 +159,7 @@ static const Uint8 GLES2_Fragment_TextureBGR[] = SHADER_PRELOGUE" \
"const mat3 matrix = mat3( 1, 1, 1,\n" \
" 0, -0.3441, 1.772,\n" \
" 1.402, -0.7141, 0);\n" \
"\n" \
#define BT601_SHADER_CONSTANTS \
"// YUV offset \n" \
@ -161,6 +169,7 @@ static const Uint8 GLES2_Fragment_TextureBGR[] = SHADER_PRELOGUE" \
"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
" 0, -0.3918, 2.0172,\n" \
" 1.596, -0.813, 0);\n" \
"\n" \
#define BT709_SHADER_CONSTANTS \
"// YUV offset \n" \
@ -170,23 +179,18 @@ static const Uint8 GLES2_Fragment_TextureBGR[] = SHADER_PRELOGUE" \
"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
" 0, -0.2132, 2.1124,\n" \
" 1.7927, -0.5329, 0);\n" \
"\n" \
#define YUV_SHADER_PROLOGUE \
SHADER_PRELOGUE \
"uniform sampler2D u_texture;\n" \
"uniform sampler2D u_texture_u;\n" \
"uniform sampler2D u_texture_v;\n" \
"varying vec4 v_color;\n" \
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n" \
"varying highp vec2 v_texCoord;\n" \
"#else\n" \
"varying vec2 v_texCoord;\n" \
"#endif\n" \
"varying mediump vec4 v_color;\n" \
"varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;\n" \
"\n" \
#define YUV_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" mediump vec3 yuv;\n" \
@ -207,7 +211,6 @@ SHADER_PRELOGUE \
"}" \
#define NV12_RA_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" mediump vec3 yuv;\n" \
@ -227,7 +230,6 @@ SHADER_PRELOGUE \
"}" \
#define NV12_RG_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" mediump vec3 yuv;\n" \
@ -247,7 +249,6 @@ SHADER_PRELOGUE \
"}" \
#define NV21_SHADER_BODY \
"\n" \
"void main()\n" \
"{\n" \
" mediump vec3 yuv;\n" \
@ -267,61 +268,61 @@ SHADER_PRELOGUE \
"}" \
/* YUV to ABGR conversion */
static const Uint8 GLES2_Fragment_TextureYUVJPEG[] = \
static const char GLES2_Fragment_TextureYUVJPEG[] = \
YUV_SHADER_PROLOGUE \
JPEG_SHADER_CONSTANTS \
YUV_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureYUVBT601[] = \
static const char GLES2_Fragment_TextureYUVBT601[] = \
YUV_SHADER_PROLOGUE \
BT601_SHADER_CONSTANTS \
YUV_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureYUVBT709[] = \
static const char GLES2_Fragment_TextureYUVBT709[] = \
YUV_SHADER_PROLOGUE \
BT709_SHADER_CONSTANTS \
YUV_SHADER_BODY \
;
/* NV12 to ABGR conversion */
static const Uint8 GLES2_Fragment_TextureNV12JPEG[] = \
static const char GLES2_Fragment_TextureNV12JPEG[] = \
YUV_SHADER_PROLOGUE \
JPEG_SHADER_CONSTANTS \
NV12_RA_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureNV12BT601_RA[] = \
static const char GLES2_Fragment_TextureNV12BT601_RA[] = \
YUV_SHADER_PROLOGUE \
BT601_SHADER_CONSTANTS \
NV12_RA_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureNV12BT601_RG[] = \
static const char GLES2_Fragment_TextureNV12BT601_RG[] = \
YUV_SHADER_PROLOGUE \
BT601_SHADER_CONSTANTS \
NV12_RG_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureNV12BT709_RA[] = \
static const char GLES2_Fragment_TextureNV12BT709_RA[] = \
YUV_SHADER_PROLOGUE \
BT709_SHADER_CONSTANTS \
NV12_RA_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureNV12BT709_RG[] = \
static const char GLES2_Fragment_TextureNV12BT709_RG[] = \
YUV_SHADER_PROLOGUE \
BT709_SHADER_CONSTANTS \
NV12_RG_SHADER_BODY \
;
/* NV21 to ABGR conversion */
static const Uint8 GLES2_Fragment_TextureNV21JPEG[] = \
static const char GLES2_Fragment_TextureNV21JPEG[] = \
YUV_SHADER_PROLOGUE \
JPEG_SHADER_CONSTANTS \
NV21_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureNV21BT601[] = \
static const char GLES2_Fragment_TextureNV21BT601[] = \
YUV_SHADER_PROLOGUE \
BT601_SHADER_CONSTANTS \
NV21_SHADER_BODY \
;
static const Uint8 GLES2_Fragment_TextureNV21BT709[] = \
static const char GLES2_Fragment_TextureNV21BT709[] = \
YUV_SHADER_PROLOGUE \
BT709_SHADER_CONSTANTS \
NV21_SHADER_BODY \
@ -329,30 +330,69 @@ static const Uint8 GLES2_Fragment_TextureNV21BT709[] = \
#endif
/* Custom Android video format texture */
static const Uint8 GLES2_Fragment_TextureExternalOES[] = " \
#extension GL_OES_EGL_image_external : require\n\
precision mediump float; \
uniform samplerExternalOES u_texture; \
varying vec4 v_color;\n\
#ifdef GL_FRAGMENT_PRECISION_HIGH\n\
varying highp vec2 v_texCoord;\n\
#else\n\
varying vec2 v_texCoord;\n\
#endif\n\
\
void main() \
{ \
gl_FragColor = texture2D(u_texture, v_texCoord); \
gl_FragColor *= v_color; \
} \
";
static const char GLES2_Fragment_TextureExternalOES_Prologue[] = \
"#extension GL_OES_EGL_image_external : require\n" \
"\n" \
;
static const char GLES2_Fragment_TextureExternalOES[] = \
"uniform samplerExternalOES u_texture;\n" \
"varying mediump vec4 v_color;\n" \
"varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;\n" \
"\n" \
"void main()\n" \
"{\n" \
" gl_FragColor = texture2D(u_texture, v_texCoord);\n" \
" gl_FragColor *= v_color;\n" \
"}\n" \
;
/*************************************************************************************************
* Shader selector *
*************************************************************************************************/
const Uint8 *GLES2_GetShader(GLES2_ShaderType type)
const char *GLES2_GetShaderPrologue(GLES2_ShaderType type)
{
switch (type) {
case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES:
return GLES2_Fragment_TextureExternalOES_Prologue;
default:
return "";
}
}
const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type)
{
switch (type) {
case GLES2_SHADER_FRAGMENT_INCLUDE_UNDEF_PRECISION:
return GLES2_Fragment_Include_Undef_Precision;
case GLES2_SHADER_FRAGMENT_INCLUDE_BEST_TEXCOORD_PRECISION:
return GLES2_Fragment_Include_Best_Texture_Precision;
case GLES2_SHADER_FRAGMENT_INCLUDE_MEDIUM_TEXCOORD_PRECISION:
return GLES2_Fragment_Include_Medium_Texture_Precision;
case GLES2_SHADER_FRAGMENT_INCLUDE_HIGH_TEXCOORD_PRECISION:
return GLES2_Fragment_Include_High_Texture_Precision;
default:
return "";
}
}
GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint()
{
const char *texcoord_hint = SDL_GetHint("SDL_RENDER_OPENGLES2_TEXCOORD_PRECISION");
GLES2_ShaderIncludeType value = GLES2_SHADER_FRAGMENT_INCLUDE_BEST_TEXCOORD_PRECISION;
if (texcoord_hint) {
if (SDL_strcmp(texcoord_hint, "undefined") == 0)
return GLES2_SHADER_FRAGMENT_INCLUDE_UNDEF_PRECISION;
if (SDL_strcmp(texcoord_hint, "high") == 0)
return GLES2_SHADER_FRAGMENT_INCLUDE_HIGH_TEXCOORD_PRECISION;
if (SDL_strcmp(texcoord_hint, "medium") == 0)
return GLES2_SHADER_FRAGMENT_INCLUDE_MEDIUM_TEXCOORD_PRECISION;
}
return value;
}
const char *GLES2_GetShader(GLES2_ShaderType type)
{
switch (type) {
case GLES2_SHADER_VERTEX_DEFAULT:

View file

@ -25,6 +25,15 @@
#if SDL_VIDEO_RENDER_OGL_ES2
typedef enum
{
GLES2_SHADER_FRAGMENT_INCLUDE_NONE = 0,
GLES2_SHADER_FRAGMENT_INCLUDE_BEST_TEXCOORD_PRECISION,
GLES2_SHADER_FRAGMENT_INCLUDE_MEDIUM_TEXCOORD_PRECISION,
GLES2_SHADER_FRAGMENT_INCLUDE_HIGH_TEXCOORD_PRECISION,
GLES2_SHADER_FRAGMENT_INCLUDE_UNDEF_PRECISION,
GLES2_SHADER_FRAGMENT_INCLUDE_COUNT
} GLES2_ShaderIncludeType;
typedef enum
{
@ -47,11 +56,15 @@ typedef enum
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601,
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709,
#endif
/* Shaders beyond this point are optional and not cached at render creation */
GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES,
GLES2_SHADER_COUNT
} GLES2_ShaderType;
const Uint8 *GLES2_GetShader(GLES2_ShaderType type);
extern const char *GLES2_GetShaderPrologue(GLES2_ShaderType type);
extern const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type);
extern const char *GLES2_GetShader(GLES2_ShaderType type);
extern GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint(void);
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */

View file

@ -40,7 +40,9 @@ SDL_CreateMutex(void)
SDL_mutex *mutex;
/* Allocate mutex memory */
mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex));
mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex));
#if !SDL_THREADS_DISABLED
if (mutex) {
/* Create the mutex semaphore, with initial value 1 */
mutex->sem = SDL_CreateSemaphore(1);
@ -53,6 +55,8 @@ SDL_CreateMutex(void)
} else {
SDL_OutOfMemory();
}
#endif /* !SDL_THREADS_DISABLED */
return mutex;
}

View file

@ -329,7 +329,7 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
if (dst->format->BitsPerPixel < 8) {
if (count == 1) {
const SDL_Rect *r = &rects[0];
if (r->x == 0 && r->y == 0 && r->w == dst->w && r->w == dst->h) {
if (r->x == 0 && r->y == 0 && r->w == dst->w && r->h == dst->h) {
if (dst->format->BitsPerPixel == 4) {
Uint8 b = (((Uint8) color << 4) | (Uint8) color);
SDL_memset(dst->pixels, b, dst->h * dst->pitch);

View file

@ -436,6 +436,7 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
return SDL_PIXELFORMAT_RGB24;
#endif
}
break;
case 32:
if (Rmask == 0) {
return SDL_PIXELFORMAT_RGB888;

View file

@ -160,7 +160,7 @@ static VideoBootStrap *bootstrap[] = {
#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
#ifdef __MACOSX__
#if defined(__MACOSX__) && defined(SDL_VIDEO_DRIVER_COCOA)
/* Support for Mac OS X fullscreen spaces */
extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
@ -1335,7 +1335,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
return 0;
}
#ifdef __MACOSX__
#if defined(__MACOSX__) && defined(SDL_VIDEO_DRIVER_COCOA)
/* if the window is going away and no resolution change is necessary,
do nothing, or else we may trigger an ugly double-transition
*/
@ -3148,7 +3148,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
return SDL_FALSE;
}
#ifdef __MACOSX__
#if defined(__MACOSX__) && defined(SDL_VIDEO_DRIVER_COCOA)
if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
if (Cocoa_IsWindowInFullscreenSpace(window)) {
return SDL_FALSE;

View file

@ -29,12 +29,11 @@
#include "SDL_shape.h"
#include "../SDL_shape_internals.h"
typedef struct {
NSGraphicsContext* context;
SDL_bool saved;
SDL_ShapeTree* shape;
} SDL_ShapeData;
@interface SDL_ShapeData : NSObject
@property (nonatomic) NSGraphicsContext* context;
@property (nonatomic) SDL_bool saved;
@property (nonatomic) SDL_ShapeTree* shape;
@end
extern SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window);
extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);

View file

@ -27,6 +27,18 @@
#include "SDL_cocoashape.h"
#include "../SDL_sysvideo.h"
@implementation SDL_ShapeData
@end
@interface SDL_CocoaClosure : NSObject
@property (nonatomic) NSView* view;
@property (nonatomic) NSBezierPath* path;
@property (nonatomic) SDL_Window* window;
@end
@implementation SDL_CocoaClosure
@end
SDL_WindowShaper*
Cocoa_CreateShaper(SDL_Window* window)
{ @autoreleasepool
@ -46,30 +58,26 @@ Cocoa_CreateShaper(SDL_Window* window)
result->userx = result->usery = 0;
window->shaper = result;
data = (SDL_ShapeData *)SDL_malloc(sizeof(SDL_ShapeData));
result->driverdata = data;
data->context = [windata.nswindow graphicsContext];
data->saved = SDL_FALSE;
data->shape = NULL;
data = [[SDL_ShapeData alloc] init];
data.context = [windata.nswindow graphicsContext];
data.saved = SDL_FALSE;
data.shape = NULL;
/* TODO: There's no place to release this... */
result->driverdata = (void*) CFBridgingRetain(data);
resized_properly = Cocoa_ResizeWindowShape(window);
SDL_assert(resized_properly == 0);
return result;
}}
typedef struct {
NSView* view;
NSBezierPath* path;
SDL_Window* window;
} SDL_CocoaClosure;
void
ConvertRects(SDL_ShapeTree* tree, void* closure)
{
SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure;
SDL_CocoaClosure* data = (__bridge SDL_CocoaClosure*)closure;
if(tree->kind == OpaqueShape) {
NSRect rect = NSMakeRect(tree->data.shape.x,data->window->h - tree->data.shape.y,tree->data.shape.w,tree->data.shape.h);
[data->path appendBezierPathWithRect:[data->view convertRect:rect toView:nil]];
NSRect rect = NSMakeRect(tree->data.shape.x, data.window->h - tree->data.shape.y, tree->data.shape.w, tree->data.shape.h);
[data.path appendBezierPathWithRect:[data.view convertRect:rect toView:nil]];
}
}
@ -77,26 +85,28 @@ int
Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
{ @autoreleasepool
{
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
SDL_ShapeData* data = (__bridge SDL_ShapeData*)shaper->driverdata;
SDL_WindowData* windata = (__bridge SDL_WindowData*)shaper->window->driverdata;
SDL_CocoaClosure closure;
if(data->saved == SDL_TRUE) {
[data->context restoreGraphicsState];
data->saved = SDL_FALSE;
SDL_CocoaClosure* closure;
if(data.saved == SDL_TRUE) {
[data.context restoreGraphicsState];
data.saved = SDL_FALSE;
}
/*[data->context saveGraphicsState];*/
/*data->saved = SDL_TRUE;*/
[NSGraphicsContext setCurrentContext:data->context];
/*[data.context saveGraphicsState];*/
/*data.saved = SDL_TRUE;*/
[NSGraphicsContext setCurrentContext:data.context];
[[NSColor clearColor] set];
NSRectFill([windata.sdlContentView frame]);
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
data.shape = SDL_CalculateShapeTree(*shape_mode, shape);
closure = [[SDL_CocoaClosure alloc] init];
closure.view = windata.sdlContentView;
closure.path = [NSBezierPath bezierPath];
closure.window = shaper->window;
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
SDL_TraverseShapeTree(data.shape, &ConvertRects, (__bridge void*)closure);
[closure.path addClip];
return 0;
@ -104,11 +114,11 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
int
Cocoa_ResizeWindowShape(SDL_Window *window)
{
SDL_ShapeData* data = window->shaper->driverdata;
{ @autoreleasepool {
SDL_ShapeData* data = (__bridge SDL_ShapeData*)window->shaper->driverdata;
SDL_assert(data != NULL);
return 0;
}
}}
#endif /* SDL_VIDEO_DRIVER_COCOA */

View file

@ -299,6 +299,9 @@ GetHintCtrlClickEmulateRightClick()
static NSUInteger
GetWindowWindowedStyle(SDL_Window * window)
{
/* IF YOU CHANGE ANY FLAGS IN HERE, PLEASE READ
the NSWindowStyleMaskBorderless comments in SetupWindowData()! */
/* always allow miniaturization, otherwise you can't programatically
minimize the window, whether there's a title bar or not */
NSUInteger style = NSWindowStyleMaskMiniaturizable;
@ -1641,7 +1644,7 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview,
/* NSWindowStyleMaskBorderless is zero, and it's possible to be
Resizeable _and_ borderless, so we can't do a simple bitwise AND
of NSWindowStyleMaskBorderless here. */
if ((style & ~NSWindowStyleMaskResizable) == NSWindowStyleMaskBorderless) {
if ((style & ~(NSWindowStyleMaskResizable|NSWindowStyleMaskMiniaturizable)) == NSWindowStyleMaskBorderless) {
window->flags |= SDL_WINDOW_BORDERLESS;
} else {
window->flags &= ~SDL_WINDOW_BORDERLESS;

View file

@ -23,8 +23,8 @@
#if SDL_VIDEO_DRIVER_OFFSCREEN
#include "../SDL_egl_c.h"
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
#include "SDL_offscreenwindow.h"

View file

@ -145,8 +145,9 @@ Wayland_HasScreenKeyboardSupport(_THIS)
* input protocol, make sure we don't have any physical keyboards either.
*/
SDL_VideoData *driverdata = _this->driverdata;
return (driverdata->input->keyboard == NULL &&
driverdata->text_input_manager != NULL);
SDL_bool haskeyboard = (driverdata->input != NULL) && (driverdata->input->keyboard != NULL);
SDL_bool hastextmanager = (driverdata->text_input_manager != NULL);
return (!haskeyboard && hastextmanager);
}
#endif /* SDL_VIDEO_DRIVER_WAYLAND */

View file

@ -204,7 +204,7 @@ SDL_WAYLAND_SYM(bool, libdecor_configuration_get_content_size, (struct libdecor_
int *))
SDL_WAYLAND_SYM(bool, libdecor_configuration_get_window_state, (struct libdecor_configuration *,\
enum libdecor_window_state *))
SDL_WAYLAND_SYM(bool, libdecor_dispatch, (struct libdecor *, int))
SDL_WAYLAND_SYM(int, libdecor_dispatch, (struct libdecor *, int))
#endif
#undef SDL_WAYLAND_MODULE

View file

@ -445,6 +445,7 @@ WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) != 0);
SDL_ToggleModState(KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) != 0);
WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
} else {
RECT rect;
@ -693,7 +694,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
actually being the foreground window, but this appears to get called in all cases where
the global foreground window changes to and from this window. */
WIN_UpdateFocus(data->window, !!wParam);
WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
}
break;
@ -1163,13 +1163,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect;
int x, y;
int w, h;
int display_index = data->window->display_index;
if (data->initializing || data->in_border_change) {
break;
}
/* When the window is minimized it's resized to the dock icon size, ignore this */
if ((data->window->flags & SDL_WINDOW_MINIMIZED) != 0) {
if (IsIconic(hwnd)) {
break;
}
@ -1203,7 +1204,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Forces a WM_PAINT event */
InvalidateRect(hwnd, NULL, FALSE);
WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
if (data->window->display_index != display_index) {
/* Display changed, check ICC profile */
WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
}
}
break;

View file

@ -1408,10 +1408,16 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
void
WIN_GetDrawableSize(const SDL_Window *window, int *w, int *h)
{
const SDL_WindowData *data = ((SDL_WindowData *)window->driverdata);
HWND hwnd = data->hwnd;
HWND hwnd;
RECT rect;
if (!window || !(window->driverdata)) {
*w = 0;
*h = 0;
return;
}
hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
if (GetClientRect(hwnd, &rect)) {
*w = rect.right;
*h = rect.bottom;

View file

@ -127,7 +127,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo)
if (vinfo->class == PseudoColor || vinfo->class == StaticColor) {
switch (vinfo->depth) {
case 8:
return SDL_PIXELTYPE_INDEX8;
return SDL_PIXELFORMAT_INDEX8;
case 4:
if (BitmapBitOrder(display) == LSBFirst) {
return SDL_PIXELFORMAT_INDEX4LSB;

View file

@ -693,7 +693,7 @@ surface_testOverflow(void *arg)
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface);
surface = SDL_CreateRGBSurfaceFrom(buf, 7, 1, 1, 3, 0, 0, 0, 0);
surface = SDL_CreateRGBSurfaceFrom(buf, 17, 1, 1, 3, 0, 0, 0, 0);
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface);

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 2020 Collabora Ltd.
Copyright (C) 2020-2022 Collabora Ltd.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -935,12 +935,22 @@ static const GuessTest guess_tests[] =
}
};
#if ULONG_MAX == 0xFFFFFFFFUL
# define SwapLongLE(X) SDL_SwapLE32(X)
#else
/* assume 64-bit */
# define SwapLongLE(X) SDL_SwapLE64(X)
#endif
/* The Linux kernel provides capability info in EVIOCGBIT and in /sys
* as an array of unsigned long in native byte order, rather than an array
* of bytes, an array of native-endian 32-bit words or an array of
* native-endian 64-bit words like you might have reasonably expected.
* The order of words in the array is always lowest-valued first: for
* instance, the first unsigned long in abs[] contains the bit representing
* absolute axis 0 (ABS_X).
*
* The constant arrays above provide test data in little-endian, because
* that's the easiest representation for hard-coding into a test like this.
* On a big-endian platform we need to byteswap it, one unsigned long at a
* time, to match what the kernel would produce. This requires us to choose
* an appropriate byteswapping function for the architecture's word size. */
SDL_COMPILE_TIME_ASSERT(sizeof_long, sizeof(unsigned long) == 4 || sizeof(unsigned long) == 8);
#define SwapLongLE(X) \
((sizeof(unsigned long) == 4) ? SDL_SwapLE32(X) : SDL_SwapLE64(X))
static int
run_test(void)

View file

@ -173,7 +173,7 @@ main(int argc, char *argv[])
quit(2);
}
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context));
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (context == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);

View file

@ -612,7 +612,7 @@ main(int argc, char *argv[])
return 0;
}
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context));
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (context == NULL) {
SDL_Log("Out of memory!\n");
quit(2);

View file

@ -522,7 +522,7 @@ main(int argc, char *argv[])
return 0;
}
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context));
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context));
if (context == NULL) {
SDL_Log("Out of memory!\n");
quit(2);

View file

@ -106,7 +106,7 @@ main(int argc, char **argv)
SDL_ClearError();
/* Create effects. */
SDL_memset(&efx, 0, sizeof(efx));
SDL_memset(efx, 0, sizeof(efx));
nefx = 0;
supported = SDL_HapticQuery(haptic);