From 98930ae886a74f1f671f632024c44f5aec281839 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 2 Oct 2024 00:51:01 +0100 Subject: [PATCH 1/2] Update bindings --- External/SDL | 2 +- SDL3-CS.Tests/MainCallbacksTest.cs | 6 +-- SDL3-CS/SDL3/ClangSharp/SDL_clipboard.g.cs | 4 ++ SDL3-CS/SDL3/ClangSharp/SDL_filesystem.g.cs | 9 ++++- SDL3-CS/SDL3/ClangSharp/SDL_gpu.g.cs | 37 +++++++++++++------ SDL3-CS/SDL3/ClangSharp/SDL_loadso.g.cs | 11 ++++-- SDL3-CS/SDL3/ClangSharp/SDL_main.g.cs | 2 +- SDL3-CS/SDL3/ClangSharp/SDL_mutex.g.cs | 30 +++++++++++++++ SDL3-CS/SDL3/ClangSharp/SDL_pixels.g.cs | 9 +---- SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs | 11 +++++- SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs | 4 ++ SDL3-CS/SDL3/ClangSharp/SDL_storage.g.cs | 4 +- SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs | 9 ++--- .../SDL3/ClangSharp/SDL_system.Android.g.cs | 5 --- SDL3-CS/SDL3/ClangSharp/SDL_system.g.cs | 4 ++ SDL3-CS/SDL3/ClangSharp/SDL_video.g.cs | 2 +- 16 files changed, 104 insertions(+), 45 deletions(-) diff --git a/External/SDL b/External/SDL index 97d1056..34033d5 160000 --- a/External/SDL +++ b/External/SDL @@ -1 +1 @@ -Subproject commit 97d1056e16d44f67df3b19e1fac8378399ae5f3d +Subproject commit 34033d58389053b718757dbec01a04ee575c31e3 diff --git a/SDL3-CS.Tests/MainCallbacksTest.cs b/SDL3-CS.Tests/MainCallbacksTest.cs index d3424f3..2ebd0d5 100644 --- a/SDL3-CS.Tests/MainCallbacksTest.cs +++ b/SDL3-CS.Tests/MainCallbacksTest.cs @@ -49,7 +49,7 @@ protected virtual SDL_AppResult Event(SDL_Event e) return SDL_AppResult.SDL_APP_CONTINUE; } - protected virtual void Quit() + protected virtual void Quit(SDL_AppResult result) { } @@ -93,11 +93,11 @@ private static SDL_AppResult AppEvent(IntPtr appState, SDL_Event* e) } [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])] - private static void AppQuit(IntPtr appState) + private static void AppQuit(IntPtr appState, SDL_AppResult result) { using var objectHandle = new ObjectHandle(appState, true); if (objectHandle.GetTarget(out var target)) - target.Quit(); + target.Quit(result); } } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_clipboard.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_clipboard.g.cs index 0f41d88..12a0908 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_clipboard.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_clipboard.g.cs @@ -69,5 +69,9 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] public static extern SDLBool SDL_HasClipboardData([NativeTypeName("const char *")] byte* mime_type); + + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: NativeTypeName("char **")] + public static extern byte** SDL_GetClipboardMimeTypes([NativeTypeName("size_t *")] nuint* num_mime_types); } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_filesystem.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_filesystem.g.cs index 9648af1..2806487 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_filesystem.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_filesystem.g.cs @@ -66,6 +66,13 @@ public partial struct SDL_PathInfo public SDL_Time access_time; } + public enum SDL_EnumerationResult + { + SDL_ENUM_CONTINUE, + SDL_ENUM_SUCCESS, + SDL_ENUM_FAILURE, + } + public static unsafe partial class SDL3 { [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetBasePath", ExactSpelling = true)] @@ -86,7 +93,7 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] - public static extern SDLBool SDL_EnumerateDirectory([NativeTypeName("const char *")] byte* path, [NativeTypeName("SDL_EnumerateDirectoryCallback")] delegate* unmanaged[Cdecl] callback, [NativeTypeName("void*")] IntPtr userdata); + public static extern SDLBool SDL_EnumerateDirectory([NativeTypeName("const char *")] byte* path, [NativeTypeName("SDL_EnumerateDirectoryCallback")] delegate* unmanaged[Cdecl] callback, [NativeTypeName("void*")] IntPtr userdata); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_gpu.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_gpu.g.cs index 60b46a2..289f74e 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_gpu.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_gpu.g.cs @@ -152,12 +152,18 @@ public enum SDL_GPUTextureFormat SDL_GPU_TEXTUREFORMAT_R16_UINT, SDL_GPU_TEXTUREFORMAT_R16G16_UINT, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT, + SDL_GPU_TEXTUREFORMAT_R32_UINT, + SDL_GPU_TEXTUREFORMAT_R32G32_UINT, + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT, SDL_GPU_TEXTUREFORMAT_R8_INT, SDL_GPU_TEXTUREFORMAT_R8G8_INT, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT, SDL_GPU_TEXTUREFORMAT_R16_INT, SDL_GPU_TEXTUREFORMAT_R16G16_INT, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT, + SDL_GPU_TEXTUREFORMAT_R32_INT, + SDL_GPU_TEXTUREFORMAT_R32G32_INT, + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB, @@ -745,14 +751,14 @@ public partial struct SDL_GPURasterizerState [NativeTypeName("bool")] public SDLBool enable_depth_bias; + [NativeTypeName("bool")] + public SDLBool enable_depth_clip; + [NativeTypeName("Uint8")] public byte padding1; [NativeTypeName("Uint8")] public byte padding2; - - [NativeTypeName("Uint8")] - public byte padding3; } public partial struct SDL_GPUMultisampleState @@ -882,10 +888,10 @@ public unsafe partial struct SDL_GPUComputePipelineCreateInfo public uint num_readonly_storage_buffers; [NativeTypeName("Uint32")] - public uint num_writeonly_storage_textures; + public uint num_readwrite_storage_textures; [NativeTypeName("Uint32")] - public uint num_writeonly_storage_buffers; + public uint num_readwrite_storage_buffers; [NativeTypeName("Uint32")] public uint num_uniform_buffers; @@ -1008,7 +1014,7 @@ public unsafe partial struct SDL_GPUTextureSamplerBinding public SDL_GPUSampler* sampler; } - public unsafe partial struct SDL_GPUStorageBufferWriteOnlyBinding + public unsafe partial struct SDL_GPUStorageBufferReadWriteBinding { public SDL_GPUBuffer* buffer; @@ -1025,7 +1031,7 @@ public unsafe partial struct SDL_GPUStorageBufferWriteOnlyBinding public byte padding3; } - public unsafe partial struct SDL_GPUStorageTextureWriteOnlyBinding + public unsafe partial struct SDL_GPUStorageTextureReadWriteBinding { public SDL_GPUTexture* texture; @@ -1208,7 +1214,7 @@ public static unsafe partial class SDL3 public static extern void SDL_EndGPURenderPass(SDL_GPURenderPass* render_pass); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern SDL_GPUComputePass* SDL_BeginGPUComputePass(SDL_GPUCommandBuffer* command_buffer, [NativeTypeName("const SDL_GPUStorageTextureWriteOnlyBinding *")] SDL_GPUStorageTextureWriteOnlyBinding* storage_texture_bindings, [NativeTypeName("Uint32")] uint num_storage_texture_bindings, [NativeTypeName("const SDL_GPUStorageBufferWriteOnlyBinding *")] SDL_GPUStorageBufferWriteOnlyBinding* storage_buffer_bindings, [NativeTypeName("Uint32")] uint num_storage_buffer_bindings); + public static extern SDL_GPUComputePass* SDL_BeginGPUComputePass(SDL_GPUCommandBuffer* command_buffer, [NativeTypeName("const SDL_GPUStorageTextureReadWriteBinding *")] SDL_GPUStorageTextureReadWriteBinding* storage_texture_bindings, [NativeTypeName("Uint32")] uint num_storage_texture_bindings, [NativeTypeName("const SDL_GPUStorageBufferReadWriteBinding *")] SDL_GPUStorageBufferReadWriteBinding* storage_buffer_bindings, [NativeTypeName("Uint32")] uint num_storage_buffer_bindings); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SDL_BindGPUComputePipeline(SDL_GPUComputePass* compute_pass, SDL_GPUComputePipeline* compute_pipeline); @@ -1291,19 +1297,23 @@ public static unsafe partial class SDL3 public static extern SDL_GPUTextureFormat SDL_GetGPUSwapchainTextureFormat(SDL_GPUDevice* device, SDL_Window* window); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern SDL_GPUTexture* SDL_AcquireGPUSwapchainTexture(SDL_GPUCommandBuffer* command_buffer, SDL_Window* window, [NativeTypeName("Uint32 *")] uint* w, [NativeTypeName("Uint32 *")] uint* h); + [return: NativeTypeName("bool")] + public static extern SDLBool SDL_AcquireGPUSwapchainTexture(SDL_GPUCommandBuffer* command_buffer, SDL_Window* window, SDL_GPUTexture** swapchain_texture, [NativeTypeName("Uint32 *")] uint* swapchain_texture_width, [NativeTypeName("Uint32 *")] uint* swapchain_texture_height); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_SubmitGPUCommandBuffer(SDL_GPUCommandBuffer* command_buffer); + [return: NativeTypeName("bool")] + public static extern SDLBool SDL_SubmitGPUCommandBuffer(SDL_GPUCommandBuffer* command_buffer); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern SDL_GPUFence* SDL_SubmitGPUCommandBufferAndAcquireFence(SDL_GPUCommandBuffer* command_buffer); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_WaitForGPUIdle(SDL_GPUDevice* device); + [return: NativeTypeName("bool")] + public static extern SDLBool SDL_WaitForGPUIdle(SDL_GPUDevice* device); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_WaitForGPUFences(SDL_GPUDevice* device, [NativeTypeName("bool")] SDLBool wait_all, [NativeTypeName("SDL_GPUFence *const *")] SDL_GPUFence** fences, [NativeTypeName("Uint32")] uint num_fences); + [return: NativeTypeName("bool")] + public static extern SDLBool SDL_WaitForGPUFences(SDL_GPUDevice* device, [NativeTypeName("bool")] SDLBool wait_all, [NativeTypeName("SDL_GPUFence *const *")] SDL_GPUFence** fences, [NativeTypeName("Uint32")] uint num_fences); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] @@ -1342,6 +1352,9 @@ public static unsafe partial class SDL3 [NativeTypeName("#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE (1u << 5)")] public const uint SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE = (1U << 5); + [NativeTypeName("#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE (1u << 6)")] + public const uint SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE = (1U << 6); + [NativeTypeName("#define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0)")] public const uint SDL_GPU_BUFFERUSAGE_VERTEX = (1U << 0); diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_loadso.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_loadso.g.cs index 65d2668..c55fd97 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_loadso.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_loadso.g.cs @@ -28,17 +28,20 @@ 3. This notice may not be removed or altered from any source distribution. namespace SDL { + public partial struct SDL_SharedObject + { + } + public static unsafe partial class SDL3 { [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [return: NativeTypeName("void*")] - public static extern IntPtr SDL_LoadObject([NativeTypeName("const char *")] byte* sofile); + public static extern SDL_SharedObject* SDL_LoadObject([NativeTypeName("const char *")] byte* sofile); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("SDL_FunctionPointer")] - public static extern IntPtr SDL_LoadFunction([NativeTypeName("void*")] IntPtr handle, [NativeTypeName("const char *")] byte* name); + public static extern IntPtr SDL_LoadFunction(SDL_SharedObject* handle, [NativeTypeName("const char *")] byte* name); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_UnloadObject([NativeTypeName("void*")] IntPtr handle); + public static extern void SDL_UnloadObject(SDL_SharedObject* handle); } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_main.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_main.g.cs index 47508a2..e40081d 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_main.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_main.g.cs @@ -37,6 +37,6 @@ public static unsafe partial class SDL3 public static extern int SDL_RunApp(int argc, [NativeTypeName("char *[]")] byte** argv, [NativeTypeName("SDL_main_func")] delegate* unmanaged[Cdecl] mainFunction, [NativeTypeName("void*")] IntPtr reserved); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern int SDL_EnterAppMainCallbacks(int argc, [NativeTypeName("char *[]")] byte** argv, [NativeTypeName("SDL_AppInit_func")] delegate* unmanaged[Cdecl] appinit, [NativeTypeName("SDL_AppIterate_func")] delegate* unmanaged[Cdecl] appiter, [NativeTypeName("SDL_AppEvent_func")] delegate* unmanaged[Cdecl] appevent, [NativeTypeName("SDL_AppQuit_func")] delegate* unmanaged[Cdecl] appquit); + public static extern int SDL_EnterAppMainCallbacks(int argc, [NativeTypeName("char *[]")] byte** argv, [NativeTypeName("SDL_AppInit_func")] delegate* unmanaged[Cdecl] appinit, [NativeTypeName("SDL_AppIterate_func")] delegate* unmanaged[Cdecl] appiter, [NativeTypeName("SDL_AppEvent_func")] delegate* unmanaged[Cdecl] appevent, [NativeTypeName("SDL_AppQuit_func")] delegate* unmanaged[Cdecl] appquit); } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_mutex.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_mutex.g.cs index 355c23e..2a2a988 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_mutex.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_mutex.g.cs @@ -23,6 +23,7 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +using System; using System.Runtime.InteropServices; namespace SDL @@ -43,6 +44,24 @@ public partial struct SDL_Condition { } + public enum SDL_InitStatus + { + SDL_INIT_STATUS_UNINITIALIZED, + SDL_INIT_STATUS_INITIALIZING, + SDL_INIT_STATUS_INITIALIZED, + SDL_INIT_STATUS_UNINITIALIZING, + } + + public partial struct SDL_InitState + { + public SDL_AtomicInt status; + + public SDL_ThreadID thread; + + [NativeTypeName("void*")] + public IntPtr reserved; + } + public static unsafe partial class SDL3 { [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] @@ -126,5 +145,16 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] public static extern SDLBool SDL_WaitConditionTimeout(SDL_Condition* cond, SDL_Mutex* mutex, [NativeTypeName("Sint32")] int timeoutMS); + + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: NativeTypeName("bool")] + public static extern SDLBool SDL_ShouldInit(SDL_InitState* state); + + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: NativeTypeName("bool")] + public static extern SDLBool SDL_ShouldQuit(SDL_InitState* state); + + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void SDL_SetInitialized(SDL_InitState* state, [NativeTypeName("bool")] SDLBool initialized); } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_pixels.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_pixels.g.cs index 3cf3853..b963cec 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_pixels.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_pixels.g.cs @@ -25,7 +25,6 @@ 3. This notice may not be removed or altered from any source distribution. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using static SDL.SDL_Colorspace; namespace SDL { @@ -255,6 +254,8 @@ public enum SDL_Colorspace : uint SDL_COLORSPACE_BT709_FULL = 0x22100421U, SDL_COLORSPACE_BT2020_LIMITED = 0x21102609U, SDL_COLORSPACE_BT2020_FULL = 0x22102609U, + SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, + SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG, } public partial struct SDL_Color @@ -403,11 +404,5 @@ public static unsafe partial class SDL3 [NativeTypeName("#define SDL_ALPHA_TRANSPARENT_FLOAT 0.0f")] public const float SDL_ALPHA_TRANSPARENT_FLOAT = 0.0f; - - [NativeTypeName("#define SDL_COLORSPACE_RGB_DEFAULT SDL_COLORSPACE_SRGB")] - public const SDL_Colorspace SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB; - - [NativeTypeName("#define SDL_COLORSPACE_YUV_DEFAULT SDL_COLORSPACE_JPEG")] - public const SDL_Colorspace SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG; } } diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs index de381da..d596e60 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_render.g.cs @@ -59,6 +59,13 @@ public partial struct SDL_Renderer public partial struct SDL_Texture { + public SDL_PixelFormat format; + + public int w; + + public int h; + + public int refcount; } public static unsafe partial class SDL3 @@ -203,11 +210,11 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] - public static extern SDLBool SDL_SetRenderLogicalPresentation(SDL_Renderer* renderer, int w, int h, SDL_RendererLogicalPresentation mode, SDL_ScaleMode scale_mode); + public static extern SDLBool SDL_SetRenderLogicalPresentation(SDL_Renderer* renderer, int w, int h, SDL_RendererLogicalPresentation mode); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] - public static extern SDLBool SDL_GetRenderLogicalPresentation(SDL_Renderer* renderer, int* w, int* h, SDL_RendererLogicalPresentation* mode, SDL_ScaleMode* scale_mode); + public static extern SDLBool SDL_GetRenderLogicalPresentation(SDL_Renderer* renderer, int* w, int* h, SDL_RendererLogicalPresentation* mode); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs index ce169ba..41ce84f 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs @@ -193,6 +193,10 @@ public static unsafe partial class SDL3 [return: NativeTypeName("Uint32")] public static extern uint SDL_crc32([NativeTypeName("Uint32")] uint crc, [NativeTypeName("const void *")] IntPtr data, [NativeTypeName("size_t")] nuint len); + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: NativeTypeName("Uint32")] + public static extern uint SDL_murmur3_32([NativeTypeName("const void *")] IntPtr data, [NativeTypeName("size_t")] nuint len, [NativeTypeName("Uint32")] uint seed); + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("void*")] public static extern IntPtr SDL_memcpy([NativeTypeName("void*")] IntPtr dst, [NativeTypeName("const void *")] IntPtr src, [NativeTypeName("size_t")] nuint len); diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_storage.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_storage.g.cs index 6013cb0..72d5289 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_storage.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_storage.g.cs @@ -40,7 +40,7 @@ public unsafe partial struct SDL_StorageInterface public delegate* unmanaged[Cdecl] ready; [NativeTypeName("bool (*)(void *, const char *, SDL_EnumerateDirectoryCallback, void *)")] - public delegate* unmanaged[Cdecl], IntPtr, SDLBool> enumerate; + public delegate* unmanaged[Cdecl], IntPtr, SDLBool> enumerate; [NativeTypeName("bool (*)(void *, const char *, SDL_PathInfo *)")] public delegate* unmanaged[Cdecl] info; @@ -111,7 +111,7 @@ public static unsafe partial class SDL3 [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] - public static extern SDLBool SDL_EnumerateStorageDirectory(SDL_Storage* storage, [NativeTypeName("const char *")] byte* path, [NativeTypeName("SDL_EnumerateDirectoryCallback")] delegate* unmanaged[Cdecl] callback, [NativeTypeName("void*")] IntPtr userdata); + public static extern SDLBool SDL_EnumerateStorageDirectory(SDL_Storage* storage, [NativeTypeName("const char *")] byte* path, [NativeTypeName("SDL_EnumerateDirectoryCallback")] delegate* unmanaged[Cdecl] callback, [NativeTypeName("void*")] IntPtr userdata); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs index 1951a05..f9dc6a8 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_surface.g.cs @@ -41,11 +41,7 @@ public enum SDL_FlipMode SDL_FLIP_VERTICAL, } - public partial struct SDL_SurfaceData - { - } - - public unsafe partial struct SDL_Surface + public partial struct SDL_Surface { public SDL_SurfaceFlags flags; @@ -62,7 +58,8 @@ public unsafe partial struct SDL_Surface public int refcount; - public SDL_SurfaceData* @internal; + [NativeTypeName("void*")] + public IntPtr reserved; } public static unsafe partial class SDL3 diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_system.Android.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_system.Android.g.cs index b552f88..589c1dc 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_system.Android.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_system.Android.g.cs @@ -45,11 +45,6 @@ public static unsafe partial class SDL3 [SupportedOSPlatform("Android")] public static extern int SDL_GetAndroidSDKVersion(); - [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [return: NativeTypeName("bool")] - [SupportedOSPlatform("Android")] - public static extern SDLBool SDL_IsAndroidTV(); - [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] [SupportedOSPlatform("Android")] diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_system.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_system.g.cs index eed7c36..0b88298 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_system.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_system.g.cs @@ -37,6 +37,10 @@ public static unsafe partial class SDL3 [return: NativeTypeName("bool")] public static extern SDLBool SDL_IsTablet(); + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: NativeTypeName("bool")] + public static extern SDLBool SDL_IsTV(); + [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SDL_OnApplicationWillTerminate(); diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_video.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_video.g.cs index 69a7930..a9dd11d 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_video.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_video.g.cs @@ -545,7 +545,7 @@ public static unsafe partial class SDL3 public static extern IntPtr SDL_EGL_GetWindowSurface(SDL_Window* window); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void SDL_EGL_SetAttributeCallbacks([NativeTypeName("SDL_EGLAttribArrayCallback")] delegate* unmanaged[Cdecl] platformAttribCallback, [NativeTypeName("SDL_EGLIntArrayCallback")] delegate* unmanaged[Cdecl] surfaceAttribCallback, [NativeTypeName("SDL_EGLIntArrayCallback")] delegate* unmanaged[Cdecl] contextAttribCallback); + public static extern void SDL_EGL_SetAttributeCallbacks([NativeTypeName("SDL_EGLAttribArrayCallback")] delegate* unmanaged[Cdecl] platformAttribCallback, [NativeTypeName("SDL_EGLIntArrayCallback")] delegate* unmanaged[Cdecl] surfaceAttribCallback, [NativeTypeName("SDL_EGLIntArrayCallback")] delegate* unmanaged[Cdecl] contextAttribCallback, [NativeTypeName("void*")] IntPtr userdata); [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: NativeTypeName("bool")] From 05c7ec057c1c05307c73dbb5bb73d0e3b02fae76 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 2 Oct 2024 02:13:12 +0100 Subject: [PATCH 2/2] Add some missing macros --- SDL3-CS.Tests/TestInterface.cs | 44 ++++++++++++++++++++++++++++++++++ SDL3-CS/SDL3/SDL_audio.cs | 4 ++++ SDL3-CS/SDL3/SDL_stdinc.cs | 14 +++++++++++ 3 files changed, 62 insertions(+) create mode 100644 SDL3-CS.Tests/TestInterface.cs diff --git a/SDL3-CS.Tests/TestInterface.cs b/SDL3-CS.Tests/TestInterface.cs new file mode 100644 index 0000000..2eeeff8 --- /dev/null +++ b/SDL3-CS.Tests/TestInterface.cs @@ -0,0 +1,44 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; + +namespace SDL.Tests +{ + [TestFixture] + public class TestInterface + { + [Test] + public unsafe void TestIOInterface() + { + SDL_IOStreamInterface iface; + + SDL3.SDL_INIT_INTERFACE(out iface); + + Assert.That(iface.version, Is.EqualTo(sizeof(SDL_IOStreamInterface))); + Assert.That(iface.size == null); + Assert.That(iface.seek == null); + Assert.That(iface.read == null); + Assert.That(iface.write == null); + Assert.That(iface.flush == null); + Assert.That(iface.close == null); + } + + [Test] + public unsafe void TestIOInterfaceManual() + { + SDL_IOStreamInterface iface = new SDL_IOStreamInterface + { + version = (uint)sizeof(SDL_IOStreamInterface), + }; + + Assert.That(iface.version, Is.EqualTo(sizeof(SDL_IOStreamInterface))); + Assert.That(iface.size == null); + Assert.That(iface.seek == null); + Assert.That(iface.read == null); + Assert.That(iface.write == null); + Assert.That(iface.flush == null); + Assert.That(iface.close == null); + } + } +} diff --git a/SDL3-CS/SDL3/SDL_audio.cs b/SDL3-CS/SDL3/SDL_audio.cs index 8f7e3ef..09829b9 100644 --- a/SDL3-CS/SDL3/SDL_audio.cs +++ b/SDL3-CS/SDL3/SDL_audio.cs @@ -11,6 +11,10 @@ public enum SDL_AudioDeviceID : UInt32; public static partial class SDL3 { + [Macro] + public static SDL_AudioFormat SDL_DEFINE_AUDIO_FORMAT(UInt16 signed, UInt16 bigendian, UInt16 @float, UInt16 size) => + (SDL_AudioFormat)(((UInt16)(signed) << 15) | ((UInt16)(bigendian) << 12) | ((UInt16)(@float) << 8) | ((size) & (UInt16)SDL_AUDIO_MASK_BITSIZE)); + [Constant] public static readonly SDL_AudioFormat SDL_AUDIO_S16 = BitConverter.IsLittleEndian ? SDL_AudioFormat.SDL_AUDIO_S16LE : SDL_AudioFormat.SDL_AUDIO_S16BE; diff --git a/SDL3-CS/SDL3/SDL_stdinc.cs b/SDL3-CS/SDL3/SDL_stdinc.cs index b13d02f..8897df5 100644 --- a/SDL3-CS/SDL3/SDL_stdinc.cs +++ b/SDL3-CS/SDL3/SDL_stdinc.cs @@ -46,6 +46,20 @@ public partial class SDL3 [Macro] public static uint SDL_FOURCC(byte A, byte B, byte C, byte D) => (uint)((A << 0) | (B << 8) | (C << 16) | (D << 24)); + [Macro] + public static unsafe void SDL_INIT_INTERFACE(out SDL_IOStreamInterface iface) + { + iface = default; + iface.version = (uint)sizeof(SDL_IOStreamInterface); + } + + [Macro] + public static unsafe void SDL_INIT_INTERFACE(out SDL_StorageInterface iface) + { + iface = default; + iface.version = (uint)sizeof(SDL_StorageInterface); + } + public static unsafe void SDL_free(void* mem) => SDL_free((IntPtr)mem); } }