mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Add vendor:wgpu
This commit is contained in:
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//+build !linux
|
||||
//+build !windows
|
||||
//+build !darwin
|
||||
package wgpu_glfw_glue
|
||||
|
||||
#panic("package wgpu/glfwglue is not supported on the current target")
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package wgpu_glfw_glue
|
||||
|
||||
import "vendor:glfw"
|
||||
import "vendor:wgpu"
|
||||
import CA "vendor:darwin/QuartzCore"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.Surface {
|
||||
ns_window := glfw.GetCocoaWindow(window)
|
||||
ns_window->contentView()->setWantsLayer(true)
|
||||
metal_layer := CA.MetalLayer_layer()
|
||||
ns_window->contentView()->setLayer(metal_layer)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceDescriptorFromMetalLayer,
|
||||
},
|
||||
layer = rawptr(metal_layer),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
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() == glfw.PLATFORM_WAYLAND {
|
||||
display := glfw.GetWaylandDisplay()
|
||||
surface := glfw.GetWaylandWindow(window)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface{
|
||||
chain = {
|
||||
sType = .SurfaceDescriptorFromWaylandSurface,
|
||||
},
|
||||
display = display,
|
||||
surface = surface,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
display := glfw.GetX11Display()
|
||||
window := glfw.GetX11Window(window)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow{
|
||||
chain = {
|
||||
sType = .SurfaceDescriptorFromXlibWindow,
|
||||
},
|
||||
display = display,
|
||||
window = u64(window),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package wgpu_glfw_glue
|
||||
|
||||
import win "core:sys/windows"
|
||||
|
||||
import "vendor:glfw"
|
||||
import "vendor:wgpu"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.Surface {
|
||||
hwnd := glfw.GetWin32Window(window)
|
||||
hinstance := win.GetModuleHandleW(nil)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceDescriptorFromWindowsHWND,
|
||||
},
|
||||
hinstance = rawptr(hinstance),
|
||||
hwnd = rawptr(hwnd),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user