Skip to content

Commit 1b8d6d0

Browse files
BeyleyPerksey
andauthored
Add EGL display and surface to INativeWindow (#1167)
* Add EGL display and surface to INativeWindow * Update src/Windowing/Silk.NET.GLFW/GlfwNativeWindow.cs Co-authored-by: Dylan Perks <11160611+Perksey@users.noreply.github.com> * Update INativeWindow.cs * Update SdlNativeWindow.cs * Update src/Core/Silk.NET.Core/Contexts/INativeWindow.cs Co-authored-by: Dylan Perks <11160611+Perksey@users.noreply.github.com> Co-authored-by: Dylan Perks <11160611+Perksey@users.noreply.github.com>
1 parent 300ae1b commit 1b8d6d0

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/Core/Silk.NET.Core/Contexts/INativeWindow.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ public interface INativeWindow
7474

7575
/// <summaray>
7676
/// The handle to use for DirectX applications. This will be the Win32 Hwnd on Windows, and it will be the GLFW
77-
/// or SDL handle on non-windows platforms for use with dxvk-native. May not be null.
77+
/// or SDL handle on non-windows platforms for use with native builds of DXVK. May not be null.
7878
/// </summary>
7979
nint? DXHandle { get; }
80+
81+
/// <summary>
82+
/// The handles for the EGL display and EGL surface. May not be null.
83+
/// </summary>
84+
(nint? Display, nint? Surface)? EGL { get; }
8085
}
8186
}

src/Core/Silk.NET.Core/Contexts/NativeWindowFlags.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public enum NativeWindowFlags : ulong
2121
Android = 1 << 16,
2222
Vivante = 1 << 17,
2323
OS2 = 1 << 18,
24-
Haiku = 1 << 19
24+
Haiku = 1 << 19,
25+
EGL = 1 << 20,
2526
}
2627
}

src/Windowing/Silk.NET.GLFW/GlfwNativeWindow.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ public unsafe GlfwNativeWindow(Glfw api, WindowHandle* window) : this()
6565
{
6666
Kind |= NativeWindowFlags.Wayland;
6767
Wayland = ((nint) ((delegate* unmanaged[Cdecl]<void*>) getWaylandDisplay)(),
68-
(nint) ((delegate* unmanaged[Cdecl]<WindowHandle*, void*>) getWaylandWindow)(window));
68+
(nint) ((delegate* unmanaged[Cdecl]<WindowHandle*, void*>) getWaylandWindow)(window));
69+
}
70+
71+
if (api.Context.TryGetProcAddress("glfwGetEGLDisplay", out var getEGLDisplay) &&
72+
api.Context.TryGetProcAddress("glfwGetEGLSurface", out var getEGLSurface))
73+
{
74+
Kind |= NativeWindowFlags.EGL;
75+
EGL = ((nint) ((delegate* unmanaged[Cdecl]<void*>) getEGLDisplay)(),
76+
(nint) ((delegate* unmanaged[Cdecl]<WindowHandle*, void*>) getEGLSurface)(window));
6977
}
7078
}
7179
public NativeWindowFlags Kind { get; }
@@ -80,5 +88,6 @@ public unsafe GlfwNativeWindow(Glfw api, WindowHandle* window) : this()
8088
public nint? Glfw { get; }
8189
public nint? Sdl { get; }
8290
public nint? DXHandle { get; }
91+
public (nint? Display, nint? Surface)? EGL { get; }
8392
}
8493
}

src/Windowing/Silk.NET.SDL/SdlNativeWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,6 @@ public unsafe SdlNativeWindow(Sdl api, Window* window) : this()
9999
public nint? Glfw { get; }
100100
public nint? Sdl { get; }
101101
public nint? DXHandle { get; }
102+
public (nint? Display, nint? Surface)? EGL { get; }
102103
}
103104
}

0 commit comments

Comments
 (0)