gdx-teaVM is a backend solution to run 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 and freetype extension use emscripten to convert C++ to Javascript/WebAssembly. Box2d and Bullet use a custom parser (jParser) to help bind javascript code.
- gdx-tests
- demo-cubocy
- demo-superjumper
- test-freetype
- test-bullet-wasm
- test-box2d-wasm
- micronaut-libgdx-teavm
- 6dof-vehicle (source)
// 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/" }
}
gdxTeaVMVersion = "1.0.0-SNAPSHOT"
// In teaVM module
dependencies {
implementation "com.github.xpenatan.gdx-teavm:backend-teavm:$project.gdxTeaVMVersion"
// Bullet extension
implementation "com.github.xpenatan.gdx-teavm:gdx-bullet-teavm:$project.gdxTeaVMVersion"
// Box2D extension
implementation "com.github.xpenatan.gdx-teavm:gdx-box2d-teavm:$project.gdxTeaVMVersion"
// FreeType extension
implementation "com.github.xpenatan.gdx-teavm:gdx-freetype-teavm:$project.gdxTeaVMVersion"
}
- Box2D (WIP)¹
- Bullet Physics (WIP)²
- FreeType
¹: Box2D extension is WIP, please check if the class/method your game use is in webidl file. If not, you can use gdx-box2d-gwt.
²: Bullet extension is WIP, please check if the class/method your game use is in webidl file. This extension does not support some custom c++ code from libgdx bullet.
A WIP standalone tool to convert your libgdx game in .jar or .class format to javascript. Example
Note: The compiled jar game should not be obfuscated.
Setup: TODO