mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Add sdl2glue to vendor:wgpu package + triangle example
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
package wgpu_sdl2_glue
|
||||
|
||||
import "vendor:sdl2"
|
||||
import "vendor:wgpu"
|
||||
import CA "vendor:darwin/QuartzCore"
|
||||
import NS "core:sys/darwin/Foundation"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surface {
|
||||
window_info: sdl2.SysWMinfo
|
||||
sdl2.GetWindowWMInfo(window, &window_info)
|
||||
ns_window := cast(^NS.Window)window_info.info.cocoa.window
|
||||
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),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user