LearnWebGPU-Code
LearnWebGPU-Code copied to clipboard
How to correctly bind GLFW3 WebGPU Extension for python
Hello, First of all, A very well written tutorials. I'm really enjoying it. Now the problem:
- glfw3 has a python bindings using ctypes.
- Let's say bindings for webgpu is also available using ctypes and wgpu_native.dll.
How do I wrap GLFW3 WebGPU Extension or this
WGPUSurface glfwGetWGPUSurface(WGPUInstance instance, GLFWwindow* window);
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.
# https://github.com/FlorianRhiem/pyGLFW/blob/master/glfw/__init__.py#L2893
# This fuction is returning None
print(glfw.get_window_user_pointer(window))
# https://github.com/FlorianRhiem/pyGLFW/blob/master/glfw/__init__.py#L1573
# This function is returning an int
print(glfw.get_win32_window(window))
On the wgpu side
# 1. We create a descriptor
desc = wgpu.InstanceDescriptor()
desc.nextInChain = None
# 2. We create the instance using this descriptor
instance = wgpu.CreateInstance(desc)
We have an instance and window as ctypes object but how do I pass them glfw extension function?
Prashant