Merge pull request #70 from Susko3/update-bindings

Update SDL3 bindings
This commit is contained in:
Dan Balasescu 2024-05-18 21:48:46 +09:00 committed by GitHub
commit 9ef6d54186
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 54 additions and 67 deletions

View File

@ -1,39 +0,0 @@
/*
<auto-generated/>
C# bindings for Simple DirectMedia Layer.
Original copyright notice of input files:
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
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;
}
}

View File

@ -161,7 +161,7 @@ namespace SDL
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 @@ namespace SDL
[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;
}
}

View File

@ -82,7 +82,7 @@ namespace SDL
[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;

View File

@ -269,6 +269,9 @@ namespace SDL
[NativeTypeName("#define SDL_HINT_JOYSTICK_HIDAPI_PS4 \"SDL_JOYSTICK_HIDAPI_PS4\"")]
public static ReadOnlySpan<byte> 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<byte> 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<byte> SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE => "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE"u8;

View File

@ -66,16 +66,16 @@ namespace SDL
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);

View File

@ -562,5 +562,11 @@ namespace SDL
[NativeTypeName("#define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER \"SDL.texture.vulkan.texture\"")]
public static ReadOnlySpan<byte> 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);
}
}

View File

@ -48,8 +48,7 @@ namespace SDL
public unsafe partial struct SDL_Surface
{
[NativeTypeName("Uint32")]
public uint flags;
public SDL_SurfaceFlags flags;
public SDL_PixelFormat* format;
@ -205,23 +204,20 @@ namespace SDL
[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<byte> SDL_PROP_SURFACE_COLORSPACE_NUMBER => "SDL.surface.colorspace"u8;

View File

@ -35,5 +35,14 @@ namespace SDL
[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;
}
}

View File

@ -58,5 +58,8 @@ namespace SDL
[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);
}
}

View File

@ -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);
}
}

View File

@ -1,11 +1,24 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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);
}
}

View File

@ -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"),