فهرست منبع

fixed many oversights

Slashscreen 7 ماه پیش
والد
کامیت
2f82d4e325
3فایلهای تغییر یافته به همراه56 افزوده شده و 46 حذف شده
  1. 8 13
      vendor/wgpu/sdl3glue/glue_darwin.odin
  2. 31 22
      vendor/wgpu/sdl3glue/glue_linux.odin
  3. 17 11
      vendor/wgpu/sdl3glue/glue_windows.odin

+ 8 - 13
vendor/wgpu/sdl3glue/glue_darwin.odin

@@ -1,22 +1,17 @@
 package wgpu_sdl3_glue
 
-import    "vendor:sdl3"
-import    "vendor:wgpu"
-import CA "vendor:darwin/QuartzCore"
-import NS "core:sys/darwin/Foundation"
+import "vendor:sdl3"
+import "vendor:wgpu"
 
 GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
-	ns_window := cast(^NS.Window)sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_COCOA_WINDOW_POINTER, nil)
-	metal_layer := CA.MetalLayer_layer()
-	ns_window->contentView()->setLayer(metal_layer)
+	view := sdl3.Metal_CreateView(window)
+	metal_layer := sdl3.Metal_GetLayer(view)
 	return wgpu.InstanceCreateSurface(
 		instance,
-		&wgpu.SurfaceDescriptor{
-			nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer{
-				chain = wgpu.ChainedStruct{
-					sType = .SurfaceDescriptorFromMetalLayer,
-				},
-				layer = rawptr(metal_layer),
+		&wgpu.SurfaceDescriptor {
+			nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer {
+				chain = wgpu.ChainedStruct{sType = .SurfaceDescriptorFromMetalLayer},
+				layer = metal_layer,
 			},
 		},
 	)

+ 31 - 22
vendor/wgpu/sdl3glue/glue_linux.odin

@@ -3,43 +3,52 @@ package wgpu_sdl3_glue
 import "vendor:sdl3"
 import "vendor:wgpu"
 
-@(private="file")
-DRIVER_X11: cstring = "x11"
-@(private="file")
-DRIVER_WAYLAND: cstring = "wayland"
 
 GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
-	if sdl3.strcmp(sdl3.GetCurrentVideoDriver(), DRIVER_WAYLAND) == 0 {
-		display := sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_X11_DISPLAY_POINTER, nil)
-		surface := sdl3.GetNumberProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_X11_WINDOW_NUMBER, 0)
+	switch sdl3.GetCurrentVideoDriver() {
+	case "x11":
+		display := sdl3.GetPointerProperty(
+			sdl3.GetWindowProperties(window),
+			sdl3.PROP_WINDOW_X11_DISPLAY_POINTER,
+			nil,
+		)
+		surface := sdl3.GetNumberProperty(
+			sdl3.GetWindowProperties(window),
+			sdl3.PROP_WINDOW_X11_WINDOW_NUMBER,
+			0,
+		)
 		return wgpu.InstanceCreateSurface(
 			instance,
-			&wgpu.SurfaceDescriptor{
-				nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface{
-					chain = {
-						sType = .SurfaceDescriptorFromWaylandSurface,
-					},
+			&wgpu.SurfaceDescriptor {
+				nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface {
+					chain = {sType = .SurfaceDescriptorFromWaylandSurface},
 					display = display,
 					surface = surface,
 				},
 			},
 		)
-	} else if sdl3.strcmp(sdl3.GetCurrentVideoDriver(), DRIVER_X11) == 0 {
-		display := sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nil)
-		surface := sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WAYLAND_SURFACE_POINTER, 0)
+	case "wayland":
+		display := sdl3.GetPointerProperty(
+			sdl3.GetWindowProperties(window),
+			sdl3.PROP_WINDOW_WAYLAND_DISPLAY_POINTER,
+			nil,
+		)
+		surface := sdl3.GetPointerProperty(
+			sdl3.GetWindowProperties(window),
+			sdl3.PROP_WINDOW_WAYLAND_SURFACE_POINTER,
+			0,
+		)
 		return wgpu.InstanceCreateSurface(
 			instance,
-			&wgpu.SurfaceDescriptor{
-				nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow{
-					chain = {
-						sType = .SurfaceDescriptorFromXlibWindow,
-					},
+			&wgpu.SurfaceDescriptor {
+				nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow {
+					chain = {sType = .SurfaceDescriptorFromXlibWindow},
 					display = display,
-					window  = u64(window),
+					window = u64(window),
 				},
 			},
 		)
-	} else {
+	case:
 		panic("wgpu sdl3 glue: unsupported platform, expected Wayland or X11")
 	}
 }

+ 17 - 11
vendor/wgpu/sdl3glue/glue_windows.odin

@@ -2,21 +2,27 @@ package wgpu_sdl3_glue
 
 import win "core:sys/windows"
 
-import  "vendor:sdl3"
-import  "vendor:wgpu"
+import "vendor:sdl3"
+import "vendor:wgpu"
 
 GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
-	hwnd := sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WIN32_HWND_POINTER, nil)
-	hinstance := win.GetModuleHandleW(nil)
+	hwnd := sdl3.GetPointerProperty(
+		sdl3.GetWindowProperties(window),
+		sdl3.PROP_WINDOW_WIN32_HWND_POINTER,
+		nil,
+	)
+	hinstance := sdl3.GetPointerProperty(
+		sdl3.GetWindowProperties(window),
+		sdl3.PROP_WINDOW_WIN32_INSTANCE_POINTER,
+		nil,
+	)
 	return wgpu.InstanceCreateSurface(
 		instance,
-		&wgpu.SurfaceDescriptor{
-			nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND{
-				chain = wgpu.ChainedStruct{
-					sType = .SurfaceDescriptorFromWindowsHWND,
-				},
-				hinstance = rawptr(hinstance),
-				hwnd = rawptr(hwnd),
+		&wgpu.SurfaceDescriptor {
+			nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND {
+				chain = wgpu.ChainedStruct{sType = .SurfaceDescriptorFromWindowsHWND},
+				hinstance = hinstance,
+				hwnd = hwnd,
 			},
 		},
 	)