mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-29 14:38:25 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
100
brutal.glfw/Brutal.Glfw/Manual/Glfw.PInvoke.cs
Normal file
100
brutal.glfw/Brutal.Glfw/Manual/Glfw.PInvoke.cs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
namespace Brutal.GlfwApi;
|
||||
|
||||
public static unsafe partial class Glfw
|
||||
{
|
||||
public static partial class PInvoke
|
||||
{
|
||||
[LibraryImport(Dll, EntryPoint = "glfwGetCurrentContext")]
|
||||
private static partial GlfwWindowHandle* _GetCurrentContext();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static GlfwWindowHandle* GetCurrentContext()
|
||||
{
|
||||
Log.Trace();
|
||||
return _GetCurrentContext();
|
||||
}
|
||||
|
||||
[LibraryImport(Dll, EntryPoint = "glfwGetProcAddress")]
|
||||
private static partial nint _GetProcAddress(byte* procName);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static nint GetProcAddress(byte* procName)
|
||||
{
|
||||
Log.Trace();
|
||||
return _GetProcAddress(procName);
|
||||
}
|
||||
|
||||
// PFN_vkGetInstanceProcAddr is a function pointer value; the generator emits `nint*`
|
||||
// for typedef'd function pointers, which is incorrect for a by-value parameter.
|
||||
[LibraryImport(Dll, EntryPoint = "glfwInitVulkanLoader")]
|
||||
private static partial void _InitVulkanLoader(nint loader);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InitVulkanLoader(nint loader)
|
||||
{
|
||||
Log.Trace();
|
||||
_InitVulkanLoader(loader);
|
||||
}
|
||||
|
||||
// This one is implemented manually to avoid the need for difficult marshaling
|
||||
[LibraryImport(
|
||||
Dll,
|
||||
EntryPoint = "glfwCreateWindow",
|
||||
StringMarshalling = StringMarshalling.Custom,
|
||||
StringMarshallingCustomType = typeof(CustomStringMarshaller)
|
||||
)]
|
||||
private static unsafe partial GlfwWindowHandle* _CreateWindow(
|
||||
int width,
|
||||
int height,
|
||||
string title,
|
||||
GlfwMonitor monitor,
|
||||
GlfwWindowHandle* share
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static GlfwWindowHandle* CreateWindow(
|
||||
int width,
|
||||
int height,
|
||||
string title,
|
||||
GlfwMonitor monitor,
|
||||
GlfwWindowHandle* share
|
||||
)
|
||||
{
|
||||
Log.Trace();
|
||||
return _CreateWindow(width, height, title, monitor, share);
|
||||
}
|
||||
|
||||
[LibraryImport(
|
||||
Dll,
|
||||
EntryPoint = "glfwSetClipboardString",
|
||||
StringMarshalling = StringMarshalling.Custom,
|
||||
StringMarshallingCustomType = typeof(CustomStringMarshaller)
|
||||
)]
|
||||
private static unsafe partial void _SetClipboardString(GlfwWindowHandle* window, string @string);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SetClipboardString(GlfwWindowHandle* window, string @string)
|
||||
{
|
||||
Log.Trace();
|
||||
_SetClipboardString(window, @string);
|
||||
}
|
||||
|
||||
[LibraryImport(
|
||||
Dll,
|
||||
EntryPoint = "glfwGetClipboardString",
|
||||
StringMarshalling = StringMarshalling.Custom,
|
||||
StringMarshallingCustomType = typeof(CustomStringMarshaller)
|
||||
)]
|
||||
private static unsafe partial string? _GetClipboardString(GlfwWindowHandle* window);
|
||||
|
||||
// Returns null when the clipboard is empty or its contents cannot be converted to UTF-8
|
||||
// (GlfwErrorCode.FormatUnavailable) - the CustomStringMarshaller preserves GLFW's NULL
|
||||
// failure sentinel rather than collapsing it to an empty string.
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? GetClipboardString(GlfwWindowHandle* window)
|
||||
{
|
||||
Log.Trace();
|
||||
return _GetClipboardString(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue