Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SDL_Vulkan_GetInstanceExtensions #241

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/SDL2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#region Using Statements
using System;
using System.Diagnostics;
using System.Linq;
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
Expand Down Expand Up @@ -2431,10 +2432,26 @@ IntPtr pNames
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern SDL_bool SDL_Vulkan_GetInstanceExtensions(
IntPtr window,
out uint pCount,
ref uint pCount,
IntPtr[] pNames
);

/* window refers to an SDL_Window*.
* Only available in 2.0.6 or higher.
*/
public static SDL_bool SDL_Vulkan_GetInstanceExtensions(IntPtr window, out string[] names)
{
names = new string[0];
uint count;
SDL_bool result = SDL_Vulkan_GetInstanceExtensions(window, out count, IntPtr.Zero);
if (result == SDL_bool.SDL_FALSE) return result;
IntPtr[] pNames = new IntPtr[count];
result = SDL_Vulkan_GetInstanceExtensions(window, ref count, pNames);
if (result == SDL_bool.SDL_FALSE) return result;
names = pNames.Select(pointer => UTF8_ToManaged(pointer)).ToArray();
return result;
}

/* window refers to an SDL_Window.
* instance refers to a VkInstance.
* surface refers to a VkSurfaceKHR.
Expand Down