Kgpu

A Cross Platform Graphics API For Kotlin JVM/JS

Warning: Because WebGPU is under active development, kgpu is very unstable! Once the specification is more finalized, this will not be an issue.

Requirements:

  • JDK 11

Supported Platforms:

  • Windows 10
  • MacOS (See Issue #1)
  • Linux
  • Chrome Canary
  • Firefox Nightly

Links

Documentation

Live Example

Modules

kgpu is split into multiple modules:

  • kgpu: The core of this library (Kotlin bindings to WebGPU)
  • kcgmath: A cross platform graphics library for Kotlin based on the Rust crate cgmath
  • kshader: A library to help compile GLSL to SPIR-V

Images

Earth Example

Examples

To run the examples on Desktop:

gradlew runTriangleExample
gradlew runCubeExample
gradlew runTextureExample
gradlew runEarthExample

To run the examples on the Web:

gradlew buildWeb startWebServer

Then navigate to http://localhost:8080/index.html

How to add to Gradle (Kotlin DSL)

First you need to add the snapshots repository:

repositories {
    maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
}

Then you can add the dependency:

dependencies {
    //Add it to a kotlin multiplatform project
    implementation("io.github.kgpu:kgpu:0.1.0-SNAPSHOT")

    //Or you can add a specific platform
    implementation("io.github.kgpu:kgpu-common:0.1.0-SNAPSHOT")
    implementation("io.github.kgpu:kgpu-js:0.1.0-SNAPSHOT")
    implementation("io.github.kgpu:kgpu-jvm:0.1.0-SNAPSHOT")
}