mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
Compare commits
46 Commits
release-3.
...
release-2.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a1d1946dcb | ||
![]() |
36524373db | ||
![]() |
77f3a9cbe8 | ||
![]() |
b8dacc37b5 | ||
![]() |
a49a25671d | ||
![]() |
284cf11778 | ||
![]() |
949addc94e | ||
![]() |
23a4b9bdd6 | ||
![]() |
ce29ebc3b8 | ||
![]() |
0733ef7e3f | ||
![]() |
d1b2f1ebb5 | ||
![]() |
15496201c9 | ||
![]() |
a23b54b74a | ||
![]() |
b0a2164b2c | ||
![]() |
14bf8237c1 | ||
![]() |
cedd8e1138 | ||
![]() |
d6e939ddb5 | ||
![]() |
128c34b839 | ||
![]() |
a1026d6368 | ||
![]() |
d8b2a165af | ||
![]() |
4657d8be0d | ||
![]() |
c7950bf0c6 | ||
![]() |
0f2503cf8a | ||
![]() |
6ba5f08e5d | ||
![]() |
7bf4ca60f6 | ||
![]() |
4d78a6fad4 | ||
![]() |
59e04dcc0b | ||
![]() |
fa239a2192 | ||
![]() |
45362dfe31 | ||
![]() |
0df4d123db | ||
![]() |
ffcf32b4ff | ||
![]() |
531ddf5eb5 | ||
![]() |
abac672a2d | ||
![]() |
782862b95c | ||
![]() |
525e201728 | ||
![]() |
0680314c2a | ||
![]() |
7be77f0b3d | ||
![]() |
e70db38d60 | ||
![]() |
08e8824372 | ||
![]() |
b6661c016b | ||
![]() |
62302d08f1 | ||
![]() |
b19e2f1e56 | ||
![]() |
ac44b22a24 | ||
![]() |
84004d1e47 | ||
![]() |
329794daf3 | ||
![]() |
3739dda6bd |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -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: |
|
||||
|
@@ -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 1)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
@@ -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;
|
||||
@@ -3036,9 +3038,9 @@ if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN)
|
||||
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_options(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>")
|
||||
else()
|
||||
target_link_options(SDL2main PUBLIC "-Wl,--undefined=WinMain")
|
||||
target_link_options(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>")
|
||||
endif()
|
||||
endif()
|
||||
if (NOT ANDROID)
|
||||
|
@@ -13,7 +13,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 24
|
||||
MICRO_VERSION = 0
|
||||
MICRO_VERSION = 1
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 24
|
||||
MICRO_VERSION = 0
|
||||
MICRO_VERSION = 1
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
@@ -19,10 +19,10 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.24.0</string>
|
||||
<string>2.24.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.24.0</string>
|
||||
<string>2.24.1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@@ -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.1.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.1.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
|
@@ -59,6 +59,11 @@ if(NOT TARGET SDL2::SDL2)
|
||||
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)
|
||||
|
@@ -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
|
||||
:
|
||||
|
@@ -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
88
build-scripts/update-version.sh
Executable 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
|
||||
|
@@ -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()
|
||||
|
@@ -30,28 +30,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)
|
||||
@@ -1186,7 +1177,7 @@ macro(CheckHIDAPI)
|
||||
set(HAVE_LIBUSB TRUE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS}")
|
||||
if(HIDAPI_ONLY_LIBUSB)
|
||||
list(APPEND EXTRA_LIBS ${LIBUSB_LIBS})
|
||||
list(APPEND EXTRA_LIBS ${LIBUSB_LIBRARIES})
|
||||
elseif(OS2)
|
||||
set(SDL_LIBUSB_DYNAMIC "\"usb100.dll\"")
|
||||
else()
|
||||
|
@@ -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
33
cmake/test/main_lib.c
Normal 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;
|
||||
}
|
388
configure
vendored
388
configure
vendored
@@ -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=1
|
||||
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,59 @@ 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 :
|
||||
as_fn_error $? "GNU sort(1) is required" "$LINENO" 5
|
||||
fi
|
||||
|
||||
# Check whether --enable-largefile was given.
|
||||
if test ${enable_largefile+y}
|
||||
then :
|
||||
@@ -18227,7 +18284,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 +19121,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 +19226,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 +19412,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 +21460,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 +21715,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 +21780,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 +22773,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 +26102,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 +27998,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 +28537,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
|
||||
|
45
configure.ac
45
configure.ac
@@ -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=1
|
||||
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_ERROR([GNU sort(1) is required])])
|
||||
|
||||
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
|
||||
|
@@ -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`
|
||||
|
||||
|
@@ -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");
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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 1
|
||||
|
||||
/**
|
||||
* Macro to determine SDL version program was compiled against.
|
||||
|
@@ -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"
|
||||
)
|
||||
|
4
sdl2.m4
4
sdl2.m4
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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,14 @@ COREAUDIO_CloseDevice(_THIS)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if callback fires again, feed silence; don't call into the app. */
|
||||
SDL_AtomicSet(&this->paused, 1);
|
||||
|
||||
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 +733,10 @@ 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 +980,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 +1130,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. */
|
||||
|
@@ -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
|
||||
|
@@ -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,16 +1063,21 @@ 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 SDL_LIBUSB_DYNAMIC
|
||||
#ifdef __OS2__
|
||||
#define LOAD_LIBUSB_SYMBOL(func) \
|
||||
if (!(libusb_ctx.func = SDL_LoadFunction(libusb_ctx.libhandle,"_libusb_" #func))) {loaded = SDL_FALSE;}
|
||||
@@ -1050,6 +1085,10 @@ int SDL_hid_init(void)
|
||||
#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 +1115,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 +1180,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 +1217,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 +1236,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 +1265,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 +1295,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 +1318,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 +1343,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 +1352,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 +1370,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 +1390,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 +1424,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 +1585,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 +1597,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 +1608,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 */
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#ifdef SDL_JOYSTICK_HIDAPI
|
||||
|
||||
#ifdef SDL_LIBUSB_DYNAMIC
|
||||
#ifdef HAVE_LIBUSB
|
||||
#define HAVE_ENABLE_GAMECUBE_ADAPTORS
|
||||
#endif
|
||||
|
||||
|
@@ -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. */
|
||||
|
@@ -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));
|
||||
|
@@ -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,1,0
|
||||
PRODUCTVERSION 2,24,1,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, 1, 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, 1, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@@ -719,6 +719,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 +755,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 +1021,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;
|
||||
|
@@ -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 */
|
||||
|
@@ -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:
|
||||
|
@@ -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 */
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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 */
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -1169,7 +1169,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user