https://github.com/wgpu4k/wgpu4k-native
wgpu binding for kotlin multi platform
https://github.com/wgpu4k/wgpu4k-native
kotlin wgpu
Last synced: 4 months ago
JSON representation
wgpu binding for kotlin multi platform
- Host: GitHub
- URL: https://github.com/wgpu4k/wgpu4k-native
- Owner: wgpu4k
- License: mit
- Created: 2024-08-22T10:24:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-06T19:24:55.000Z (10 months ago)
- Last Synced: 2025-07-06T20:35:23.123Z (10 months ago)
- Topics: kotlin, wgpu
- Language: Kotlin
- Homepage:
- Size: 5.39 MB
- Stars: 19
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wgpu4k native : a Kotlin binding of wgpu library
[](https://github.com/wgpu4k/wgpu4k-native/actions/workflows/test.yml)


[](https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMIT_License)
[](https://discord.gg/qy9KQAP9Kc)
## About
This project is a WebGPU binding compatible with Desktop and Mobile.
If you are looking for an experience that also covers the web, you can use the [wgpu4k](https://github.com/wgpu4k/wgpu4k) project.
This library uses the Firefox backend written in Rust, [available here](https://github.com/gfx-rs/wgpu-native).
## How to Run the demo
1. On JVM: `./gradlew demo:desktop-and-ios:runJvm`
4. On native Macos or Linux: `./gradlew demo:desktop-and-ios:runDebugExecutable`
5. On Android, run the subproject `android` with android studio or IntelliJ IDEA!
5. On Android Native, run `./gradlew build`, then run the subproject `android-native` with android studio or IntelliJ IDEA!
6. On iOS `./gradlew demo:desktop-and-ios:assembleWgpuAppXCFramework` to build the XC Framework, then you can run the subproject `iosApp` (on demo/desktop-and-ios folder) with XCode on a iOS simulator or real device.
## How to use
[View the API reference](https://wgpu4k.github.io/wgpu4k-native/)
From a basic multiplatform project, create a common native source set and add the library:
``` kotlin
private val hierarchyTemplate = KotlinHierarchyTemplate {
/* natural hierarchy is only applied to default 'main'/'test' compilations (by default) */
withSourceSetTree(KotlinSourceSetTree.main, KotlinSourceSetTree.test)
common {
/* All compilations shall be added to the common group by default */
withCompilations { true }
group("commonNative") {
group("native") {
withNative()
group("apple") {
withApple()
group("ios") {
withIos()
}
group("tvos") {
withTvos()
}
group("watchos") {
withWatchos()
}
group("macos") {
withMacos()
}
}
group("linux") {
withLinux()
}
group("mingw") {
withMingw()
}
}
withJvm()
withAndroidTarget()
}
}
}
kotlin {
...
jvm {
compilerOptions {
jvmTarget = JvmTarget.JVM_24
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
macosArm64()
macosX64()
linuxArm64()
linuxX64()
mingwX64()
androidTarget {
compilerOptions {
jvmTarget = JvmTarget.JVM_24
}
publishLibraryVariants("release", "debug")
}
applyHierarchyTemplate(hierarchyTemplate)
sourceSets {
...
val commonNativeMain by getting {
dependencies { api("io.ygdrasil:wgpu4k-native:) }
}
...
}
...
}