Skip to content

xpenatan/gdx-jolt

Repository files navigation

gdx-jolt

Build Build Sonatype Nexus (Snapshots) Static Badge

gdx-jolt is a Java binding for the C++ library Jolt Physics, utilizing JNI for desktop and mobile platforms, and Emscripten for web platforms. It provides a one-to-one correspondence with the C++ code, meaning it mirrors the exact same class and method names. Its primary focus is to support libGDX projects.

The binding leverages jParser, a custom C/C++ build tool and WebIDL Java code generator, which automatically generates 99% of all classes. Only a small number of essential classes are coded manually, making updates to new Jolt Physics versions quick and efficient.

image

Web/TeaVM Examples:

Platform status:

Emscripten Windows Linux Mac Android iOS
  • ✅: Have a working build.
  • ❌: Build not ready.

Setup

// Use -SNAPSHOT" or any released git-tag version

// Add repository to Root gradle
repositories {
    mavenLocal()
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}

// Core module
implementation("com.github.xpenatan.gdx-jolt:jolt-core:-SNAPSHOT")
implementation("com.github.xpenatan.gdx-jolt:jolt-gdx:-SNAPSHOT")

// Desktop module
dependencies {
   implementation("com.github.xpenatan.gdx-jolt:jolt-desktop:-SNAPSHOT")
}

// TeaVM module
dependencies {
   implementation("com.github.xpenatan.gdx-jolt:jolt-teavm:-SNAPSHOT")
}

// Android module
dependencies {
   implementation("com.github.xpenatan.gdx-jolt:jolt-android:-SNAPSHOT")
}

Notes

  • In certain classes, new instances are created using Jolt.New_ instead of standard constructors. This approach is necessary due to limitations in constructor overloading within WebIDL when targeting Emscripten.
  • Methods that return an object typically return a temporary object. You should not retain a reference to it, as calling the method again with another instance will overwrite the previously returned object.
  • Classes are not disposed automatically; the dispose method must be called when they are no longer in use. However, classes in a WebIDL file marked with "NoDelete" do not require disposal.

Source Build Prerequisites

¹: Only need if you want to build from source.

To try the samples with your build, change LibExt.exampleUseRepoLibs to false in Dependencies.kt. This will allow you to use the local Jolt source code instead of the remote repository.

How to run the samples

  • Clone the repository
  • Run ./gradlew :examples:SamplesApp:desktop:SamplesApp-run-desktop

How to build from source

./gradlew download_all_sources

### Build all targets if your machine can handle:
./gradlew :jolt:jolt-build:build_project_all

### Or a single platform target:
./gradlew :jolt:jolt-build:build_project_windows64
./gradlew :jolt:jolt-build:build_project_linux64
./gradlew :jolt:jolt-build:build_project_mac64 :jolt:jolt-build:build_project_macArm
./gradlew :jolt:jolt-build:build_project_teavm

About

JoltPhysics for libgdx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages