alternative GUI for libGDX is Dear ImGui, a bloat-free graphical user interface library in C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (few dependencies).


Dear ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries. A common misunderstanding is to think that immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions are called by the user. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely. Dear ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.

First steps using kotlin-graphics’ binding)

https://github.com/kotlin-graphics/imgui/wiki/Using-libGDX These are some very simple examples, how its usage may look like:

Kotlin

  1. var f = 0fwith(ImGui) { text("Hello, world %d", 123) button("OK"){ // react } inputText("string", buf) sliderFloat("float", ::f, 0f, 1f)}

Java

  1. ImGui imgui = ImGui.INSTANCE;float[] f = {0f};imgui.text("Hello, world %d", 123);if(imgui.button("OK")) { // react}imgui.inputText("string", buf);imgui.sliderFloat("float", f, 0f, 1f);

here as:

  1. IO.fonts.addFontFromFileTTF("extraFonts/ArialUni.ttf", 18f, glyphRanges = IO.fonts.glyphRangesJapanese)!!

First steps using SpaiR’s bindings

Required Dependencies

  1. "io.github.spair:imgui-java-binding:<version>""io.github.spair:imgui-java-lwjgl3:<version>""io.github.spair:imgui-java-natives-linux:<version>""io.github.spair:imgui-java-natives-macos:<version>""io.github.spair:imgui-java-natives-windows:<version>"

Example Minimal Usage

The following instructions detail how ImGui can be used on top of a 3D scene in libGDX. 1.

  1. ImGuiImplGlfw imGuiGlfw = new ImGuiImplGlfw();ImGuiImplGl3 imGuiGl3 = new ImGuiImplGl3();
  1. create():
    1. // create 3D sceneGLFWErrorCallback.createPrint(System.err).set();if (!glfwInit()){ throw new IllegalStateException("Unable to initialize GLFW");}ImGui.createContext();final ImGuiIO io = ImGui.getIO();io.setIniFilename(null);ImGuiTools.setupFonts(io);windowHandle = ((Lwjgl3Graphics) Gdx.graphics).getWindow().getWindowHandle();imGuiGlfw.init(windowHandle, true);imGuiGl3.init(glslVersion);
  2. render():
    1. // render 3D sceneimGuiGlfw.newFrame();ImGui.newFrame();ImGui.button("I'm a Button!");ImGui.render();imGuiGl3.renderDrawData(ImGui.getDrawData());glfwSwapBuffers(windowHandle);glfwPollEvents();
  3. dispose():
    1. imGuiGl3.dispose();imGuiGlfw.dispose();ImGui.destroyContext();
    1.