Kotlin/Native bindings and window helpers for Dear ImGui on desktop.
imgui2kt provides:
- a generated Kotlin facade for the cimgui Dear ImGui API
- a simple GLFW desktop window host
- click-through and interactive overlay hosts
- Linux
linuxX64and WindowsmingwX64targets
Add the plugin from Maven Central:
// settings.gradle.kts
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories { mavenCentral() }
}// build.gradle.kts
plugins {
kotlin("multiplatform") version "2.3.20"
id("org.kvxd.imgui2kt.runtime") version "0.7.0"
}
kotlin {
linuxX64 {
binaries.executable {
entryPoint = "example.main"
}
}
}Then create src/nativeMain/kotlin/example/Main.kt:
package example
import org.kvxd.imgui2kt.ImGui
import org.kvxd.imgui2kt.desktopWindow
fun main() {
desktopWindow(title = "imgui2kt", width = 900, height = 560) { window ->
window.run {
ImGui.window("Hello") {
ImGui.textUnformatted("Dear ImGui from Kotlin/Native")
}
}
}
}Build it:
./gradlew linkDebugExecutableLinuxX64Run an example from this repository:
./gradlew :examples:simple-window:linkDebugExecutableLinuxX64To build the Windows executable from Linux:
./gradlew :examples:simple-window:linkDebugExecutableMingwX64examples/simple-window: normal desktop windowexamples/simple-overlay: click-through HUD overlayexamples/interactive-overlay: overlay that can switch between HUD and interactive input
Linux builds require:
- CMake
- C and C++ compilers
- OpenGL development files
- Wayland development files
- EGL
- xkbcommon
- pkg-config
wayland-scanner
Windows target builds use Kotlin/Native mingwX64. Cross-building from Linux also requires:
x86_64-w64-mingw32-gccx86_64-w64-mingw32-g++x86_64-w64-mingw32-windres
Publish the library and Gradle plugin to Maven Local:
./gradlew publishAllToMavenLocalPublish the library and Gradle plugin to Maven Central:
./gradlew publishAllToMavenCentralMaven Central publishing requires the Vanniktech Maven Publish credentials and signing properties to be available to Gradle.
The release version is set in gradle.properties as imgui2kt.version.