Skip to content

tom-delalande/raylib-kotlin-multiplatform

Repository files navigation

raylib-kotlin-multiplatform

AI Disclaimer: THIS PROJECT IS AI SLOP, DO NOT READ THE CODE IF YOU VALUE YOUR EYES. But it works and I would never have bothered writing this myself so now it exists. This is just a project that generates wrappers around other projects, so if it compiles it most likely works all good.

This is a Kotlin Multiplatform expects and actual for Raylib that currently targets JVM and native Desktop. This is useful because it lets your write small statically linked Raylib games in Kotlin. But also run in the JVM if you want to use JVM tooling for development (like the portability and debugging tools for example)

Check out the /sample module for an example of how to use. In particular the runJvm command which lets you run in JVM. But you can copy that entire build.gradle.kts file to get it working on a project. If I can be bothered I might see if I can include some of the build in the published library.

Here is my very simple platformer game built with this dependency: https://github.com/tom-delalande/strawberrry-platformer

Targets

Platform Status
JVM ✅ (via Jaylib)
macOS (x86_64) ✅ (via cinterop)
macOS (arm64) ✅ (via cinterop)
Linux (x64) ✅ (via cinterop)
Windows (x64) ✅ (via cinterop)
Web (WasmJS) 🚧 In progress

Architecture

The project is structured as follows:

  • library/ — The core KMP library providing a unified Raylib API across all targets via expect/actual declarations.
  • codegen/ — Code generation tool that parses raylib C headers and generates the Kotlin bindings automatically.
  • sample/ — Sample applications demonstrating usage on different platforms.
  • input/ — raylib C source (git submodule) used as input for code generation and native interop.

Usage

Add the library as a dependency in your KMP project:

// build.gradle.kts
kotlin {
    sourceSets {
        commonMain {
            dependencies {
                implementation("com.raylib.kmp:library:VERSION")
            }
        }
    }
}

See the sample/ module for runnable examples.

Development

Prerequisites

  • JDK 21
  • raylib installed on your system (for native targets)
  • On macOS: brew install raylib

Building

./gradlew build

Running samples

# JVM
./gradlew :sample:runJvm

# Native (macOS arm64)
./gradlew :sample:macosArm64MainRun

License

This project is licensed under the same terms as raylib (zlib/libpng).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages