From 25c25581840b13b400a25e371f5327ac83241fb0 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 18 May 2024 12:26:03 +0200 Subject: [PATCH] Update SDL3 bindings Updates to https://github.com/libsdl-org/SDL/commit/%206f2621438a65abae114a7210914352b4c1d9c6c3. This matches the binaries. --- SDL3-CS/SDL3/ClangSharp/SDL.g.cs | 39 ------------------------ SDL3-CS/SDL3/ClangSharp/SDL_audio.g.cs | 5 +-- SDL3-CS/SDL3/ClangSharp/SDL_cpuinfo.g.cs | 2 +- SDL3-CS/SDL3/ClangSharp/SDL_hints.g.cs | 3 ++ SDL3-CS/SDL3/ClangSharp/SDL_log.g.cs | 8 ++--- SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs | 6 ++++ SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs | 26 +++++++--------- SDL3-CS/SDL3/ClangSharp/SDL_version.g.cs | 9 ++++++ SDL3-CS/SDL3/ClangSharp/SDL_vulkan.g.cs | 3 ++ SDL3-CS/SDL3/SDL_log.cs | 4 +-- SDL3-CS/SDL3/SDL_surface.cs | 15 ++++++++- SDL3-CS/generate_bindings.py | 1 - 12 files changed, 54 insertions(+), 67 deletions(-) delete mode 100644 SDL3-CS/SDL3/ClangSharp/SDL.g.cs diff --git a/SDL3-CS/SDL3/ClangSharp/SDL.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL.g.cs deleted file mode 100644 index cab650a..0000000 --- a/SDL3-CS/SDL3/ClangSharp/SDL.g.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* - - C# bindings for Simple DirectMedia Layer. - Original copyright notice of input files: - - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -namespace SDL -{ - public static partial class SDL3 - { - [NativeTypeName("#define SDL_MAJOR_VERSION 3")] - public const int SDL_MAJOR_VERSION = 3; - - [NativeTypeName("#define SDL_MINOR_VERSION 1")] - public const int SDL_MINOR_VERSION = 1; - - [NativeTypeName("#define SDL_MICRO_VERSION 2")] - public const int SDL_MICRO_VERSION = 2; - } -} diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_audio.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_audio.g.cs index cd68d06..b42caa8 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_audio.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_audio.g.cs @@ -161,7 +161,7 @@ public static unsafe partial class SDL3 public static extern int SDL_LoadWAV([NativeTypeName("const char *")] byte* path, SDL_AudioSpec* spec, [NativeTypeName("Uint8 **")] byte** audio_buf, [NativeTypeName("Uint32 *")] uint* audio_len); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern int SDL_MixAudioFormat([NativeTypeName("Uint8 *")] byte* dst, [NativeTypeName("const Uint8 *")] byte* src, SDL_AudioFormat format, [NativeTypeName("Uint32")] uint len, int volume); + public static extern int SDL_MixAudio([NativeTypeName("Uint8 *")] byte* dst, [NativeTypeName("const Uint8 *")] byte* src, SDL_AudioFormat format, [NativeTypeName("Uint32")] uint len, float volume); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int SDL_ConvertAudioSamples([NativeTypeName("const SDL_AudioSpec *")] SDL_AudioSpec* src_spec, [NativeTypeName("const Uint8 *")] byte* src_data, int src_len, [NativeTypeName("const SDL_AudioSpec *")] SDL_AudioSpec* dst_spec, [NativeTypeName("Uint8 **")] byte** dst_data, int* dst_len); @@ -210,8 +210,5 @@ public static unsafe partial class SDL3 [NativeTypeName("#define SDL_AUDIO_DEVICE_DEFAULT_CAPTURE ((SDL_AudioDeviceID) 0xFFFFFFFE)")] public const SDL_AudioDeviceID SDL_AUDIO_DEVICE_DEFAULT_CAPTURE = ((SDL_AudioDeviceID)(0xFFFFFFFE)); - - [NativeTypeName("#define SDL_MIX_MAXVOLUME 128")] - public const int SDL_MIX_MAXVOLUME = 128; } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_cpuinfo.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_cpuinfo.g.cs index b10e4b2..8db1c30 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_cpuinfo.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_cpuinfo.g.cs @@ -82,7 +82,7 @@ public static partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("size_t")] - public static extern nuint SDL_SIMDGetAlignment(); + public static extern nuint SDL_GetSIMDAlignment(); [NativeTypeName("#define SDL_CACHELINE_SIZE 128")] public const int SDL_CACHELINE_SIZE = 128; diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_hints.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_hints.g.cs index 806a579..e5a4dce 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_hints.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_hints.g.cs @@ -269,6 +269,9 @@ public static unsafe partial class SDL3 [NativeTypeName("#define SDL_HINT_JOYSTICK_HIDAPI_PS4 \"SDL_JOYSTICK_HIDAPI_PS4\"")] public static ReadOnlySpan SDL_HINT_JOYSTICK_HIDAPI_PS4 => "SDL_JOYSTICK_HIDAPI_PS4"u8; + [NativeTypeName("#define SDL_HINT_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL \"SDL_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL\"")] + public static ReadOnlySpan SDL_HINT_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL => "SDL_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL"u8; + [NativeTypeName("#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE \"SDL_JOYSTICK_HIDAPI_PS4_RUMBLE\"")] public static ReadOnlySpan SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE => "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE"u8; diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_log.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_log.g.cs index bf25cfb..049a234 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_log.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_log.g.cs @@ -66,16 +66,16 @@ public enum SDL_LogPriority public static unsafe partial class SDL3 { [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_LogSetAllPriority(SDL_LogPriority priority); + public static extern void SDL_SetLogPriorities(SDL_LogPriority priority); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_LogSetPriority(int category, SDL_LogPriority priority); + public static extern void SDL_SetLogPriority(int category, SDL_LogPriority priority); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern SDL_LogPriority SDL_LogGetPriority(int category); + public static extern SDL_LogPriority SDL_GetLogPriority(int category); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_LogResetPriorities(); + public static extern void SDL_ResetLogPriorities(); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SDL_Log([NativeTypeName("const char *")] byte* fmt, __arglist); diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs index 0e1b012..ce1670d 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs @@ -562,5 +562,11 @@ public static unsafe partial class SDL3 [NativeTypeName("#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER \"SDL.texture.vulkan.texture\"")] public static ReadOnlySpan SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER => "SDL.texture.vulkan.texture"u8; + + [NativeTypeName("#define SDL_RENDERER_VSYNC_DISABLED 0")] + public const int SDL_RENDERER_VSYNC_DISABLED = 0; + + [NativeTypeName("#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)")] + public const int SDL_RENDERER_VSYNC_ADAPTIVE = (-1); } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs index efd53d2..fd5eba0 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs @@ -48,8 +48,7 @@ public enum SDL_FlipMode public unsafe partial struct SDL_Surface { - [NativeTypeName("Uint32")] - public uint flags; + public SDL_SurfaceFlags flags; public SDL_PixelFormat* format; @@ -205,23 +204,20 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int SDL_ReadSurfacePixel(SDL_Surface* surface, int x, int y, [NativeTypeName("Uint8 *")] byte* r, [NativeTypeName("Uint8 *")] byte* g, [NativeTypeName("Uint8 *")] byte* b, [NativeTypeName("Uint8 *")] byte* a); - [NativeTypeName("#define SDL_SWSURFACE 0")] - public const int SDL_SWSURFACE = 0; + [NativeTypeName("#define SDL_PREALLOC 0x00000001u")] + public const uint SDL_PREALLOC = 0x00000001U; - [NativeTypeName("#define SDL_PREALLOC 0x00000001")] - public const int SDL_PREALLOC = 0x00000001; + [NativeTypeName("#define SDL_RLEACCEL 0x00000002u")] + public const uint SDL_RLEACCEL = 0x00000002U; - [NativeTypeName("#define SDL_RLEACCEL 0x00000002")] - public const int SDL_RLEACCEL = 0x00000002; + [NativeTypeName("#define SDL_DONTFREE 0x00000004u")] + public const uint SDL_DONTFREE = 0x00000004U; - [NativeTypeName("#define SDL_DONTFREE 0x00000004")] - public const int SDL_DONTFREE = 0x00000004; + [NativeTypeName("#define SDL_SIMD_ALIGNED 0x00000008u")] + public const uint SDL_SIMD_ALIGNED = 0x00000008U; - [NativeTypeName("#define SDL_SIMD_ALIGNED 0x00000008")] - public const int SDL_SIMD_ALIGNED = 0x00000008; - - [NativeTypeName("#define SDL_SURFACE_USES_PROPERTIES 0x00000010")] - public const int SDL_SURFACE_USES_PROPERTIES = 0x00000010; + [NativeTypeName("#define SDL_SURFACE_USES_PROPERTIES 0x00000010u")] + public const uint SDL_SURFACE_USES_PROPERTIES = 0x00000010U; [NativeTypeName("#define SDL_PROP_SURFACE_COLORSPACE_NUMBER \"SDL.surface.colorspace\"")] public static ReadOnlySpan SDL_PROP_SURFACE_COLORSPACE_NUMBER => "SDL.surface.colorspace"u8; diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_version.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_version.g.cs index 672273c..182671a 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_version.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_version.g.cs @@ -35,5 +35,14 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetRevision", ExactSpelling = true)] [return: NativeTypeName("const char *")] public static extern byte* Unsafe_SDL_GetRevision(); + + [NativeTypeName("#define SDL_MAJOR_VERSION 3")] + public const int SDL_MAJOR_VERSION = 3; + + [NativeTypeName("#define SDL_MINOR_VERSION 1")] + public const int SDL_MINOR_VERSION = 1; + + [NativeTypeName("#define SDL_MICRO_VERSION 2")] + public const int SDL_MICRO_VERSION = 2; } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_vulkan.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_vulkan.g.cs index f8c8039..c759262 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_vulkan.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_vulkan.g.cs @@ -58,5 +58,8 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern SDL_bool SDL_Vulkan_CreateSurface(SDL_Window* window, [NativeTypeName("VkInstance")] VkInstance_T* instance, [NativeTypeName("const struct VkAllocationCallbacks *")] VkAllocationCallbacks* allocator, [NativeTypeName("VkSurfaceKHR *")] VkSurfaceKHR_T** surface); + + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void SDL_Vulkan_DestroySurface([NativeTypeName("VkInstance")] VkInstance_T* instance, [NativeTypeName("VkSurfaceKHR")] VkSurfaceKHR_T* surface, [NativeTypeName("const struct VkAllocationCallbacks *")] VkAllocationCallbacks* allocator); } } diff --git a/SDL3-CS/SDL3/SDL_log.cs b/SDL3-CS/SDL3/SDL_log.cs index 70ab926..fa8fd74 100644 --- a/SDL3-CS/SDL3/SDL_log.cs +++ b/SDL3-CS/SDL3/SDL_log.cs @@ -5,7 +5,7 @@ namespace SDL { public static partial class SDL3 { - public static void SDL_LogSetPriority(SDL_LogCategory category, SDL_LogPriority priority) => SDL_LogSetPriority((int)category, priority); - public static SDL_LogPriority SDL_LogGetPriority(SDL_LogCategory category) => SDL_LogGetPriority((int)category); + public static void SDL_SetLogPriority(SDL_LogCategory category, SDL_LogPriority priority) => SDL_SetLogPriority((int)category, priority); + public static SDL_LogPriority SDL_GetLogPriority(SDL_LogCategory category) => SDL_GetLogPriority((int)category); } } diff --git a/SDL3-CS/SDL3/SDL_surface.cs b/SDL3-CS/SDL3/SDL_surface.cs index 65e990a..0f1b7ce 100644 --- a/SDL3-CS/SDL3/SDL_surface.cs +++ b/SDL3-CS/SDL3/SDL_surface.cs @@ -1,11 +1,24 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; + namespace SDL { + [Flags] + [Typedef] + public enum SDL_SurfaceFlags : UInt32 + { + SDL_PREALLOC = SDL3.SDL_PREALLOC, + SDL_RLEACCEL = SDL3.SDL_RLEACCEL, + SDL_DONTFREE = SDL3.SDL_DONTFREE, + SDL_SIMD_ALIGNED = SDL3.SDL_SIMD_ALIGNED, + SDL_SURFACE_USES_PROPERTIES = SDL3.SDL_SURFACE_USES_PROPERTIES, + } + public static partial class SDL3 { [Macro] - public static unsafe bool SDL_MUSTLOCK(SDL_Surface* S) => (((S)->flags & SDL_RLEACCEL) != 0); + public static unsafe bool SDL_MUSTLOCK(SDL_Surface* S) => (((S)->flags & SDL_SurfaceFlags.SDL_RLEACCEL) != 0); } } diff --git a/SDL3-CS/generate_bindings.py b/SDL3-CS/generate_bindings.py index e1f891a..049e2db 100644 --- a/SDL3-CS/generate_bindings.py +++ b/SDL3-CS/generate_bindings.py @@ -79,7 +79,6 @@ def add(s: str): headers = [ - add("SDL3/SDL.h"), add("SDL3/SDL_atomic.h"), add("SDL3/SDL_audio.h"), add("SDL3/SDL_blendmode.h"),