MCPcopy Index your code
hub / github.com/SpaiR/imgui-java

github.com/SpaiR/imgui-java @v1.92.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.92.0 ↗ · + Follow
7,285 symbols 11,586 edges 420 files 2,161 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ImGui Java

JNI based binding for Dear ImGui

Github All Releases CI

Maven Central binding javadoc app javadoc

Tracks Dear ImGui v1.92.7 (docking branch).


Features

  • Generated JNI code with no third-party runtime dependencies.
  • Small footprint, direct native calls.
  • Full coverage of the public Dear ImGui API, adapted for idiomatic Java usage.
  • Multi-Viewports and Docking support (docking branch).
  • Optional FreeType font renderer for higher-quality text.
  • Bundled extensions: ImPlot, ImNodes, imgui-node-editor, ImGuizmo, ImGuiColorTextEdit, ImGuiFileDialog, ImGui Club MemoryEditor, imgui-knobs.

The repo ships three Maven artifacts:

  • imgui-java-app — high-level wrapper with bundled GLFW + OpenGL + native libs. Subclass Application, override process().
  • imgui-java-binding — the binding itself, no backend included.
  • imgui-java-lwjgl3 — ready-made GLFW/OpenGL backend on top of LWJGL3 for use with imgui-java-binding.

Backends are optional — Dear ImGui is renderer-agnostic, so feel free to copy imgui-lwjgl3 as a starting point and adapt it to your stack.

How to Try

JDK 17+ is required to run the build (Gradle's toolchain pins it). Published artifacts target Java 8 bytecode, so consuming them as a dependency only needs JDK 8+ at runtime.

git clone --recurse-submodules https://github.com/SpaiR/imgui-java.git
cd imgui-java
./gradlew :example:run
# SDL3 + SDL_GPU backend smoke test:
./gradlew :example:run -PmainClass=MainSdl

example/src/main/java/ contains a runnable showcase for every widget and extension — start with Main.java, then explore the per-extension Example*.java files.

How to Use

Pick a module based on how much control you need:

  • imgui-app — one-jar batteries-included setup (GLFW + OpenGL + Dear ImGui + native libs). Extend Application, override process(), you're done.
  • imgui-binding + imgui-lwjgl3 — bring your own backend wiring. Use this when you want to integrate ImGui into an existing render loop or a non-default GLFW/OpenGL setup.

On Apple Silicon nothing extra is needed: the published macOS native is a universal binary covering both x86_64 and aarch64.

SDL3 backend (imgui-app)

imgui-app now supports two backends via Configuration#setBackend(...):

  • Backend.GLFW (default)
  • Backend.SDL (SDL3 + SDL_GPU)

Use SDL3 by switching backend in configure(...):

@Override
protected void configure(final Configuration config) {
    config.setBackend(Backend.SDL);
}

For a ready smoke-test entry point, run MainSdl:

./gradlew :example:run -PmainClass=MainSdl

At the moment, SDL backend in imgui-app is focused on single-window flow (multi-viewport is not supported).

Application

If you don't care about OpenGL and other low-level stuff, then you can use application layer from imgui-app module. It is a one jar solution which includes: GLFW, OpenGL and Dear ImGui itself. So you only need one dependency line or one jar in classpath to make everything to work. You don't need to add separate dependencies to LWJGL or native libraries, since they are already included.

Application module is the best choice if everything you care is the GUI itself.

At the same time, Application gives options to override any life-cycle method it has. That means that if you are seeking for a bit more low-level control - you can gain it as well.

Example

A very simple application may look like this:

import imgui.ImGui;
import imgui.app.Application;
import imgui.app.Configuration;

public class Main extends Application {
    @Override
    protected void configure(Configuration config) {
        config.setTitle("Dear ImGui is Awesome!");
    }

    @Override
    public void process() {
        ImGui.text("Hello, World!");
    }

    public static void main(String[] args) {
        launch(new Main());
    }
}

Read imgui.app.Application javadoc to understand how it works under the hood.

Dependencies

Maven Central

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation "io.github.spair:imgui-java-app:${version}"
}

Maven

<dependencies>
    <dependency>
        <groupId>io.github.spair</groupId>
        <artifactId>imgui-java-app</artifactId>
        <version>${version}</version>
    </dependency>
</dependencies>

Raw Jar

  1. Go to the release page;
  2. Download java-libraries.zip;
  3. Get imgui-app-${version}-all.jar;
  4. Add the jar to your classpath.

Jar with all classifier already contains binding and lwjgl3 modules.

If you're using jar without the all classifier, add appropriate jars as well.

Both jars, with or without all classifier, have all required native libraries already.

Java Module System

If using Java 9 modules, you will need to require the imgui.app module.

Binding

Using binding without imgui-app module requires to "attach" it to the application manually. You can refer to imgui-app module to see how things are done there.

Dependencies

Maven Central

For simplicity, example of dependencies for Gradle / Maven only shows how to add natives for Windows. Feel free to add other platforms.

Native Binaries System
imgui-java-natives-windows Windows
imgui-java-natives-linux Linux
imgui-java-natives-macos macOS

Take a note, that you also need to add dependencies to LWJGL library. Examples below shows how to do it as well.

Gradle

repositories {
    mavenCentral()
}

ext {
    lwjglVersion = '3.4.1'
    imguiVersion = "${version}"
}

dependencies {
    implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

    ['', '-opengl', '-glfw'].each {
        implementation "org.lwjgl:lwjgl$it:$lwjglVersion"
        implementation "org.lwjgl:lwjgl$it::natives-windows"
    }

    implementation "io.github.spair:imgui-java-binding:$imguiVersion"
    implementation "io.github.spair:imgui-java-lwjgl3:$imguiVersion"

    implementation "io.github.spair:imgui-java-natives-windows:$imguiVersion"
}

Maven

<properties>
    <lwjgl.version>3.4.1</lwjgl.version>
    <imgui.java.version>${version}</imgui.java.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-bom</artifactId>
            <version>${lwjgl.version}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.lwjgl</groupId>
        <artifactId>lwjgl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.lwjgl</groupId>
        <artifactId>lwjgl-glfw</artifactId>
    </dependency>
    <dependency>
        <groupId>org.lwjgl</groupId>
        <artifactId>lwjgl-opengl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.lwjgl</groupId>
        <artifactId>lwjgl</artifactId>
        <classifier>natives-windows</classifier>
    </dependency>
    <dependency>
        <groupId>org.lwjgl</groupId>
        <artifactId>lwjgl-glfw</artifactId>
        <classifier>natives-windows</classifier>
    </dependency>
    <dependency>
        <groupId>org.lwjgl</groupId>
        <artifactId>lwjgl-opengl</artifactId>
        <classifier>natives-windows</classifier>
    </dependency>

    <dependency>
        <groupId>io.github.spair</groupId>
        <artifactId>imgui-java-binding</artifactId>
        <version>${imgui.java.version}</version>
    </dependency>
    <dependency>
        <groupId>io.github.spair</groupId>
        <artifactId>imgui-java-lwjgl3</artifactId>
        <version>${imgui.java.version}</version>
    </dependency>
    <dependency>
        <groupId>io.github.spair</groupId>
        <artifactId>imgui-java-natives-windows</artifactId>
        <version>${imgui.java.version}</version>
    </dependency>
</dependencies>

Raw Jars

  1. Go to the release page;
  2. Download java-libraries.zip and native-libraries.zip;
  3. Get imgui-binding-${version}.jar and imgui-lwjgl3-${version}.jar from java-libraries, and binary libraries for required OS from native-libraries archive;
  4. Add jars to your classpath;
  5. Provide a VM option with location of files from the native-libraries archive.

VM option example: - -Dimgui.library.path=${path} - -Djava.library.path=${path}

Both imgui.library.path and java.library.path are equal with the difference, that java.library.path is standard JVM option to provide native libraries.

Java Module System

If using Java 9 modules, ImGui Java has Automatic Module Names:

Package Module
imgui-java-app imgui.app
imgui-java-binding imgui.binding
imgui-java-lwjgl3 imgui.lwjgl3
imgui-java-natives-windows imgui.natives.windows
imgui-java-natives-linux imgui.natives.linux
imgui-java-natives-macos imgui.natives.macos

Extensions

All extensions are already included in the binding and can be used as is. See example/src/main/java/ for runnable demos of each.

A small, dependency-free node editor for Dear ImGui. (A good choice for simple start.) - imgui-node-editor | Example

Node Editor using ImGui. (A bit more complex than ImNodes, but has more features.) - ImGuizmo | Example

Immediate mode 3D gizmo for scene editing and other controls based on Dear ImGui. - implot | Example

Advanced 2D Plotting for Dear ImGui. - ImGuiColorTextEdit | Example

Syntax highlighting text editor for ImGui. - ImGuiFileDialog | Example

A file selection dialog built for ImGui. - ImGui Club MemoryEditor | Example

Memory editor and viewer for ImGui. - imgui-knobs | Example

A collection of knob widgets for Dear ImGui.

FreeType

By default, Dear ImGui uses stb-truetype to render fonts. There is an option to use the FreeType font renderer instead — see imgui_freetype for the differences.

This binding also supports the FreeType option. FreeType is statically pre-compiled into the published native libraries, meaning it is included by default. The compile-time default font loader stays stb_truetype; the renderer is switched at runtime via ImFontAtlas#setFreeTypeRenderer(true), which must be called before fonts atlas generation. After that you can freely use ImGuiFreeTypeBuilderFlags in your font configuration.

See example/src/main/java/Main.java for a working example.

If you prefer not to ship FreeType, you will need to build your own binaries (omit -Dfreetype=true when invoking generateLibs).

API Conventions

The binding adapts the C++ API for Java; almost everything maps directly, but two

Extension points exported contracts — how you extend this code

Decl (Interface)
(no doc)
buildSrc/src/main/kotlin/tool/generator/ast/decl.kt
DeclContainer (Interface)
(no doc)
buildSrc/src/main/kotlin/tool/generator/ast/decl.kt

Core symbols most depended-on inside this repo

getData
called by 279
example/src/main/java/ExampleDragAndDrop.java
get
called by 103
imgui-binding/src/main/java/imgui/type/ImInt.java
clone
called by 31
imgui-app/src/main/java/imgui/app/Color.java
contains
called by 25
imgui-binding/src/main/java/imgui/extension/implot/ImPlotRect.java
forEach
called by 23
imgui-binding/src/main/java/imgui/ImGuiListClipper.java
run
called by 21
imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java
get
called by 18
imgui-binding/src/main/java/imgui/type/ImString.java
checkbox
called by 16
imgui-binding/src/main/java/imgui/ImGui.java

Shape

Method 6,746
Class 426
Function 101
Enum 7
Interface 5

Languages

Java98%
Kotlin2%
C++1%

Modules by API surface

imgui-binding/src/generated/java/imgui/ImGui.java798 symbols
imgui-binding/src/generated/java/imgui/ImGuiIO.java438 symbols
imgui-binding/src/main/java/imgui/ImGui.java374 symbols
imgui-binding/src/generated/java/imgui/extension/implot/ImPlot.java322 symbols
imgui-binding/src/generated/java/imgui/ImGuiStyle.java307 symbols
imgui-binding/src/generated/java/imgui/extension/nodeditor/NodeEditor.java245 symbols
imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditor.java239 symbols
imgui-binding/src/generated/java/imgui/internal/ImGui.java223 symbols
imgui-binding/src/generated/java/imgui/internal/ImGuiDockNode.java188 symbols
imgui-binding/src/generated/java/imgui/extension/imnodes/ImNodes.java172 symbols
imgui-binding/src/generated/java/imgui/extension/implot/ImPlotStyle.java168 symbols
imgui-binding/src/generated/java/imgui/extension/nodeditor/NodeEditorStyle.java142 symbols

For agents

$ claude mcp add imgui-java \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact