https://github.com/chances/wgpu-d
Idiomatic D wrapper around wgpu-native.
https://github.com/chances/wgpu-d
3d-graphics dlang webgpu wgpu
Last synced: 4 months ago
JSON representation
Idiomatic D wrapper around wgpu-native.
- Host: GitHub
- URL: https://github.com/chances/wgpu-d
- Owner: chances
- License: mit
- Created: 2020-10-24T06:57:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-30T22:54:40.000Z (almost 2 years ago)
- Last Synced: 2025-10-11T11:08:31.765Z (8 months ago)
- Topics: 3d-graphics, dlang, webgpu, wgpu
- Language: D
- Homepage: https://chances.github.io/wgpu-d
- Size: 27.3 MB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# wgpu-d
[](https://code.dlang.org/packages/wgpu-d)

[](https://codecov.io/gh/chances/wgpu-d)
D bindings to [wgpu-native](https://github.com/gfx-rs/wgpu-native) as an idiomatic wrapper around the library.
Targets wgpu-native [`v0.17.0.2`](https://github.com/gfx-rs/wgpu-native/releases/tag/v0.17.0.2).
## Usage
```json
"dependencies": {
"wgpu-d": "0.3.1"
}
```
### Examples
You can try the examples before installing:
#### Headless
`dub run wgpu-d:headless`
#### Triangle
`dub run wgpu-d:triangle`
#### Cube
`dub run wgpu-d:cube`
## Development
Bindings to [`wgpu.h`](https://github.com/gfx-rs/wgpu-native/tree/v0.10.4.1/ffi) are generated dynamically on your host system and loaded by D with [ImportC](https://dlang.org/spec/importc.html). See the [`wgpu`](https://github.com/chances/wgpu-d/blob/v0.1.0/Makefile#L31-L39) Makefile task. The `wgpu` task is automatically performed as a Dub [pre-generate command](https://github.com/chances/wgpu-d/blob/v0.1.0/dub.json#L46).
### Testing
The unit test executable is patched (`patchelf` for Posix and `install_name_tool` for mac OS) to correct the library load path such that `libwgpu` is found.
See this [StackOverflow answer](https://stackoverflow.com/a/54723461/1363247).
### Upgrading wgpu-native
1. `make clean`
2. Bump the version constraint in [subprojects/wgpu.Makefile](https://github.com/chances/wgpu-d/blob/master/subprojects/wgpu.Makefile#L1).
3. `dub test`
4. Ensure the examples compile:
- `dub build wgpu-d:headless`
- `dub build wgpu-d:triangle`
- `dub build wgpu-d:cube`
5. Fix any errors in the idiomatic wrapper