gdx-teavm is a backend solution for running libGDX games directly in web browsers. It leverages TeaVM, a tool that compiles Java or Kotlin bytecode into JavaScript, enabling seamless execution of game logic within the browser environment without needing additional plugins or complex setup. Additionally, gdx-teavm incorporates Emscripten to handle some of the Java Native Interface (JNI) code, allowing for the execution of specific internal functions that require native performance.
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.
- gdx-tests (Updated 07/09/2024)
- demo-cubocy
- demo-superjumper
- test-freetype
- test-bullet-wasm
- test-box2d-wasm
- micronaut-libgdx-teavm
- 6dof-vehicle (source)
teavm-backend | LibGDX |
---|---|
1.0.5 | 1.12.1 |
1.1.0 | 1.13.1 |
// 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
}
}
// Version
gdxTeaVMVersion = "-SNAPSHOT"
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"
}
- ImGui (WIP)
- Box2d (WIP). Use GWTBox2d for now.
- Bullet (WIP)
- PhysX (WIP)
- Lua (WIP)
- FreeType (Is included in this repo)
ImGui, Box2D, Bullet, PhysX, and Lua libraries leverage Emscripten and jParser to convert C++ code to JavaScript/WebAssembly.
Important Note: Most of these projects are still works in progress and not yet production-ready. If you're interested in contributing, we welcome your involvement.