rajveermalviya / go-webgpu

Go bindings for WebGPU, a safe & cross-platform GPU abstraction
Apache License 2.0
151 stars 11 forks source link

Q: Integration with GLFW #267

Closed mokiat closed 1 year ago

mokiat commented 1 year ago

Hi,

I came across this library and would like to plug it into some existing code of mine and get started with WebGPU coding.

My framework is already based on GLFW and I was wondering if there is a trivial way to get go-webgpu to work with GLFW?

I see that the examples use gamen, however, it does not support some of the features I need (e.g. gamepad input; drag & drop) and would also mean a more substantial rewrite.

rajveermalviya commented 1 year ago

Hey,

Sure you can use go-webgpu with glfw. The examples boids, cube, triangle and triangle-msaa use glfw. Each of these examples use pretty similar functionality from glfw.

The only quirky thing right now is that glfw doesn't have an extension for webgpu surface initialisation, so we have to do it manually and to do it cross platform way in Go we have to spread the surface creation across multiple go files. see:

rajveermalviya commented 1 year ago

Now that I think about it, go-webgpu repo can host a separate module that will have this helper function - meaning wgpu module will not depend on glfw; keeping things independent.

mokiat commented 1 year ago

Hi! Thanks. I was looking at the wrong examples it seems. Sorry about that.

Having these functions available ready for use would be ideal. Aside from making it easy to get started with the library, if there are any issues in the future, they need only be fixed once.

Should I close this issue or will you be using it as reference for future work?

rajveermalviya commented 1 year ago

Closing it is fine. I'll mark it as answered

rajveermalviya commented 1 year ago

@mokiat I created wgpuext/glfw which provides the surface description creation helpers. Check out the examples for usage: boids, cube, triangle and triangle-msaa

mokiat commented 1 year ago

@rajveermalviya , thanks. Just had a look and it works very nicely.