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 project.
This library uses the Firefox backend written in Rust, available here.
- On JVM:
./gradlew demo:desktop-and-ios:runJvm
- On native Macos or Linux:
./gradlew demo:desktop-and-ios:runDebugExecutable
- On Android, run the subproject
android
with android studio ! - On iOS
./gradlew demo:desktop-and-ios:assembleWgpuAppXCFramework
to build the XC Framework, then you can run the subprojectiosApp
(on demo/desktop-and-ios folder) with XCode on a iOS simulator or real device.
From a basic multiplatform project, create a common native source set and add the library:
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_22
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
macosArm64()
macosX64()
linuxArm64()
linuxX64()
mingwX64()
androidTarget {
compilerOptions {
jvmTarget = JvmTarget.JVM_22
}
publishLibraryVariants("release", "debug")
}
applyHierarchyTemplate(hierarchyTemplate)
sourceSets {
...
val commonNativeMain by getting {
dependencies { api("io.ygdrasil:wgpu4k-native:<library version>) }
}
...
}
...
}