improve WGPU / GLFW / Wayland story by weak linking and adjusting docs

This commit is contained in:
Laytan
2024-07-18 19:28:15 +02:00
parent 0bb4cc6ce5
commit 7134015f56
4 changed files with 25 additions and 7 deletions
+5 -4
View File
@@ -3,11 +3,8 @@ package wgpu_glfw_glue
import "vendor:glfw"
import "vendor:wgpu"
// GLFW needs to be compiled with wayland support for this to work.
SUPPORT_WAYLAND :: #config(WGPU_GFLW_GLUE_SUPPORT_WAYLAND, false)
GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.Surface {
when SUPPORT_WAYLAND {
if glfw.GetPlatform != nil {
if glfw.GetPlatform() == glfw.PLATFORM_WAYLAND {
display := glfw.GetWaylandDisplay()
surface := glfw.GetWaylandWindow(window)
@@ -24,6 +21,10 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
},
)
}
if glfw.GetPlatform() != glfw.PLATFORM_X11 {
panic("wgpu glfw glue: unsupported platform, expected Wayland or X11")
}
}
display := glfw.GetX11Display()