Open prashant-saxena opened 1 year ago
With what you already have access to, porting glfw3webgpu should not take long, it's just 20 lines of C per OS: https://github.com/eliemichel/glfw3webgpu/blob/main/glfw3webgpu.c Depending on the OS, you set a different thing in the nextInChain
field of the descriptor you pass to wgpu.InstanceCreateSurface
. Let me know if you feel stuck I could have a look at it, otherwise feel free to share the result!
I have created a small shared library (glfw3webgpu.dll) using glfw3webgp.c
import glfw
import wgpu # ctypes.CDLL('wgpu_native.dll')
import wgpuglfw # ctypes.CDLL('glfw3webgpu.dll')
glfw_get_wgpu_surface = wgpuglfw.clib.glfwGetWGPUSurface
glfw_get_wgpu_surface.argtypes = [wgpu.clib.Instance, ct.POINTER(glfw._GLFWwindow)]
glfw_get_wgpu_surface.restypes = [ct.POINTER(wgpu.clib.Surface)]
# Structs are loaded in wgpu.clib and they are not available in wgpuglfw.clib, this could be the issue?
# 1. We create a descriptor
desc = wgpu.InstanceDescriptor()
desc.nextInChain = None
# 2. We create the instance using this descriptor
instance = wgpu.CreateInstance(desc)
surface = glfw_get_wgpu_surface (instance.rval, window)
print(surface) # an integer value is coming here but not Surface struct
I am stuck here completely and have no idea how to resolve this issue. I would really appreciate if someone can help me out here.
Could you share a full version of the code you currently have, including build instructions? Would save me some time to avoid trying too long to reproduce your setup!
Just give me a day or two. I think I will be able to solve this problem. I will post the results here.
Hello, First of all, A very well written tutorials. I'm really enjoying it. Now the problem:
How do I wrap GLFW3 WebGPU Extension or this
function in such a way that it can be used inside python. These two functions are the only ones that returns a window, but it seems they are not working.
On the wgpu side
We have an instance and window as ctypes object but how do I pass them glfw extension function?
Prashant