Skip to content

Add EGL display and surface to INativeWindow #1167

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

Merged
merged 5 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/Core/Silk.NET.Core/Contexts/INativeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ public interface INativeWindow

/// <summaray>
/// The handle to use for DirectX applications. This will be the Win32 Hwnd on Windows, and it will be the GLFW
/// or SDL handle on non-windows platforms for use with dxvk-native. May not be null.
/// or SDL handle on non-windows platforms for use with native builds of DXVK. May not be null.
/// </summary>
nint? DXHandle { get; }

/// <summary>
/// The handles for the EGL display and EGL surface. May not be null.
/// </summary>
(nint? Display, nint? Surface)? EGL { get; }
}
}
3 changes: 2 additions & 1 deletion src/Core/Silk.NET.Core/Contexts/NativeWindowFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum NativeWindowFlags : ulong
Android = 1 << 16,
Vivante = 1 << 17,
OS2 = 1 << 18,
Haiku = 1 << 19
Haiku = 1 << 19,
EGL = 1 << 20,
}
}
11 changes: 10 additions & 1 deletion src/Windowing/Silk.NET.GLFW/GlfwNativeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ public unsafe GlfwNativeWindow(Glfw api, WindowHandle* window) : this()
{
Kind |= NativeWindowFlags.Wayland;
Wayland = ((nint) ((delegate* unmanaged[Cdecl]<void*>) getWaylandDisplay)(),
(nint) ((delegate* unmanaged[Cdecl]<WindowHandle*, void*>) getWaylandWindow)(window));
(nint) ((delegate* unmanaged[Cdecl]<WindowHandle*, void*>) getWaylandWindow)(window));
}

if (api.Context.TryGetProcAddress("glfwGetEGLDisplay", out var getEGLDisplay) &&
api.Context.TryGetProcAddress("glfwGetEGLSurface", out var getEGLSurface))
{
Kind |= NativeWindowFlags.EGL;
EGL = ((nint) ((delegate* unmanaged[Cdecl]<void*>) getEGLDisplay)(),
(nint) ((delegate* unmanaged[Cdecl]<WindowHandle*, void*>) getEGLSurface)(window));
}

DXHandle ??= (nint)window;
Expand All @@ -81,5 +89,6 @@ public unsafe GlfwNativeWindow(Glfw api, WindowHandle* window) : this()
public nint? Glfw { get; }
public nint? Sdl { get; }
public nint? DXHandle { get; }
public (nint? Display, nint? Surface)? EGL { get; }
}
}
1 change: 1 addition & 0 deletions src/Windowing/Silk.NET.SDL/SdlNativeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@ public unsafe SdlNativeWindow(Sdl api, Window* window) : this()
public nint? Glfw { get; }
public nint? Sdl { get; }
public nint? DXHandle { get; }
public (nint? Display, nint? Surface)? EGL { get; }
}
}