diff --git a/src/win32_init.c b/src/win32_init.c index 6b6e9d08..1a66b976 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -669,7 +669,8 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform) .getEGLNativeWindow = _glfwGetEGLNativeWindowWin32, .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWin32, .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWin32, - .createWindowSurface = _glfwCreateWindowSurfaceWin32 + .createWindowSurface = _glfwCreateWindowSurfaceWin32, + .createWindowWGPUSurface = _glfwCreateWindowWGPUSurfaceWin32 }; *platform = win32; diff --git a/src/win32_platform.h b/src/win32_platform.h index 49cceba6..905c86bb 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -544,6 +544,8 @@ void _glfwGetRequiredInstanceExtensionsWin32(char** extensions); GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); +WGPUSurface _glfwCreateWindowWGPUSurfaceWin32(WGPUInstance instance, _GLFWwindow* window); + void _glfwFreeMonitorWin32(_GLFWmonitor* monitor); void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale); diff --git a/src/win32_window.c b/src/win32_window.c index 26f9684b..e1a8411a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2562,6 +2562,26 @@ VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, return err; } +typedef struct WGPUSurfaceSourceWindowsHWND { + WGPUChainedStruct chain; + void * hinstance; + void * hwnd; +} WGPUSurfaceSourceWindowsHWND; + +WGPUSurface _glfwCreateWindowWGPUSurfaceWin32(WGPUInstance instance, _GLFWwindow *window) { + WGPUSurfaceSourceWindowsHWND windowsSurface; + windowsSurface.chain.sType = WGPUSType_SurfaceSourceWindowsHWND; + windowsSurface.chain.next = NULL; + windowsSurface.hinstance = _glfw.win32.instance; + windowsSurface.hwnd = window->win32.handle; + + WGPUSurfaceDescriptor surfaceDescriptor; + surfaceDescriptor.nextInChain = &windowsSurface.chain; + surfaceDescriptor.label = (WGPUStringView){ NULL, SIZE_MAX }; + + return wgpuInstanceCreateSurface(instance, &surfaceDescriptor); +} + GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL);