Skip to content

xpenatan/gdx-teavm

Repository files navigation

Build

Sonatype Nexus (Snapshots) Sonatype Nexus (Snapshots)

gdx-teavm is a backend solution for running libgdx games in a web browser. It uses TeaVM behind the scene to convert Java/Kotlin bytecode to Javascript.

Note:

  • Reflection support is very small so only reflection used in tests will work.
  • TeaVM does not support every class methods from java package or JNI native methods. Check teaVM java classes here.
  • Kotlin discussions.
  • Box2d, Bullet, ImGui, PhysX and Freetype libraries use emscripten and jParser to convert C++ to Javascript/WebAssembly.

TeaVM Examples:

TeaVM Games:

Setup:

// Add sonatype repository to Root gradle
repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    maven { url "https://teavm.org/maven/repository/" }
    
    // If there is a problem with the teavm repository, you can try using http
    maven {
        url = uri("http://teavm.org/maven/repository/")
        isAllowInsecureProtocol = true
    }
}
// SNAPSHOT:
gdxTeaVMVersion = "-SNAPSHOT"
// RELEASE:
gdxTeaVMVersion = "[LAST_TAG_VERSION]"
// In teaVM module
dependencies {
    implementation "com.github.xpenatan.gdx-teavm:backend-teavm:$project.gdxTeaVMVersion"

    // FreeType extension
    implementation "com.github.xpenatan.gdx-teavm:gdx-freetype-teavm:$project.gdxTeaVMVersion"
}

Supported libraries: