Git Product home page Git Product logo

imgui's Introduction

dear jvm imgui

Build Status license Size Github All Releases

(This rewrite is free but, on the same line of the original library, it needs your support to sustain its development. There are many desirable features and maintenance ahead. If you are an individual using dear imgui, please consider donating via Patreon or PayPal. If your company is using dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development. E-mail: elect86 at gmail).

Monthly donations via Patreon:
Patreon

One-off donations via PayPal:
PayPal

Btc: 3DKLj6rEZNovEh6xeVp4RU3fk3WxZvFtPM


This is the Kotlin rewrite of dear imgui (AKA ImGui), a bloat-free graphical user interface library for 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 external dependencies).

Dear ImGui is designed to enable fast iterations and to 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 lacks certain features normally found in more high-level libraries.

Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.

Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine.

It doesn't provide the guarantee that dear imgui provides, but it is actually a much better fit for java/kotlin users.

Usage

Your code passes mouse/keyboard inputs and settings to Dear ImGui (see example applications for more details). After ImGui is setup, you can use it like in this example:

Kotlin
with(ImGui) {
    text("Hello, world %d", 123)
    button("Save"){
        // do stuff
    }
    inputText("string", buf)
    sliderFloat("float", ::f, 0f, 1f)
}
Java
imgui.text("Hello, world %d", 123);
if(imgui.button("Save")) {
    // do stuff
}
imgui.inputText("string", buf);
imgui.sliderFloat("float", f, 0f, 1f);

Result:

screenshot of sample code alongside its output with ImGui

(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px / Rounding: 5)

Code:

// Create a window called "My First Tool", with a menu bar.
begin("My First Tool", ::myToolActive, WindowFlag.MenuBar)
menuBar {
    menu("File") {
        menuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
        menuItem("Save", "Ctrl+S"))   { /* Do stuff */ }
        menuItem("Close", "Ctrl+W"))  { myToolActive = false }
    }
}

// Edit a color (stored as FloatArray[4] or Vec4)
colorEdit4("Color", myColor);

// Plot some values
val myValues = floatArrayOf( 0.2f, 0.1f, 1f, 0.5f, 0.9f, 2.2f )
plotLines("Frame Times", myValues)
 
// Display contents in a scrolling region
textColored(Vec4(1,1,0,1), "Important Stuff")
withChild("Scrolling") {
    for (int n = 0; n < 50; n++)
        text("%04d: Some text", n)
}
end()

Result:

screenshot of sample code alongside its output with ImGui

How it works

Check out the References section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize state duplication, state synchronization and state storage from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.

Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.

A common misunderstanding is to mistake immediate mode gui for 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. 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 allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.

Demo

You should be able to try the examples from test (tested on Windows/Mac/Linux) within minutes. If you can't, let me know!

OpenGL:

Vulkan:

You should refer to those also to learn how to use the imgui library.

The demo applications are unfortunately not yet DPI aware so expect some blurriness on a 4K screen. For DPI awareness you can load/reload your font at different scale, and scale your Style with style.ScaleAllSizes().

Ps: DEBUG = false to turn off debugs println()

Functional Programming / Domain Specific Language

All the functions are ported exactly as the original. Moreover, in order to take advantage of Functional Programming this port offers some comfortable constructs, giving the luxury to forget about some annoying and very error prone burden code such as the ending *Pop(), *end() and so on.

These constructs shine especially in Kotlin, where they are also inlined.

Let's take an original cpp sample and let's see how we can make it nicer:

    if (ImGui::TreeNode("Querying Status (Active/Focused/Hovered etc.)")) {            
        ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
        if (test_window) {            
            ImGui::Begin("Title bar Hovered/Active tests", &test_window);
            if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered() {                
                if (ImGui::MenuItem("Close")) { test_window = false; }
                ImGui::EndPopup();
            }
            ImGui::Text("whatever\n");
            ImGui::End();
        }
        ImGui::TreePop();
    }

This may become in Kotlin:

    treeNode("Querying Status (Active/Focused/Hovered etc.)") {            
        checkbox("Hovered/Active tests after Begin() for title bar testing", ::test_window)
        if (test_window)
            window ("Title bar Hovered/Active tests", ::test_window) {
                popupContextItem { // <-- This is using IsItemHovered() {                    
                    menuItem("Close") { test_window = false }
                }
                text("whatever\n")
            }
    }

Or in Java:

    treeNode("Querying Status (Active/Focused/Hovered etc.)", () -> {            
        checkbox("Hovered/Active tests after Begin() for title bar testing", test_window)
        if (test_window[0])
            window ("Title bar Hovered/Active tests", test_window, () -> {
                popupContextItem(() -> { // <-- This is using IsItemHovered() {                    
                    menuItem("Close", () -> test_window = false);
                });
                text("whatever\n");
            });
    });

The demo mixes some traditional imgui-calls with these DSL calls.

Refer to the corresponding dsl object for Kotlin or dsl_ class for Java.

Native Roadmap

Some of the goals of Omar for 2018 are:

  • Finish work on gamepad/keyboard controls. (see #787)
  • Finish work on viewports and multiple OS windows management. (see #1542)
  • Finish work on docking, tabs. (see #351)
  • Make Columns better. (they are currently pretty terrible!)
  • Make the examples look better, improve styles, improve font support, make the examples hi-DPI aware.

Rewrite Roadmap

  • finish to rewrite the last few remaining methods
  • make text input and handling robust (copy/cut/undo/redo and text filters)
  • hunt down bugs

How to retrieve it:

You can find all the instructions by mary

ImGui does not impose any platform specific dependency. Therefor users must specify runtime dependencies themselves. This should be done with great care to ensure that the dependencies versions do not conflict.

Using Gradle with the following workaround is recommended to keep the manual maintenance cost low.

import org.gradle.internal.os.OperatingSystem

repositories {
    ...
    maven("https://raw.githubusercontent.com/kotlin-graphics/mary/master")
}

dependencies {
    /*
    Each renderer will need different dependencies.
    Each one needs core.
    OpenGL needs "gl", "glfw"
    Vulkan needs "vk", "glfw"
    JOGL needs "jogl"
    OpenJFX needs "openjfx"
    
    To get all the dependencies in one sweep, create an array of the strings needed and loop through them like below.
    Any number of renderers can be added to the project like this however, you could all all of them with the array ["gl", "glfw", "core", "vk", "jogl", "openjfx"] 
    This example gets the OpenGL needed modules.
     */
    implementation("kotlin.graphics:imgui-core:1.79+05")
    implementation("kotlin.graphics:imgui-gl:1.79+05")
    implementation("kotlin.graphics:imgui-glfw:1.79+05")
	
    /*switch ( OperatingSystem.current() ) {
        case OperatingSystem.WINDOWS:
            ext.lwjglNatives = "natives-windows"
            break
        case OperatingSystem.LINUX:
            ext.lwjglNatives = "natives-linux"
            break
        case OperatingSystem.MAC_OS:
            ext.lwjglNatives = "natives-macos"
            break
    }

    // Look up which modules and versions of LWJGL are required and add setup the approriate natives.
    configurations.compile.resolvedConfiguration.getResolvedArtifacts().forEach {
        if (it.moduleVersion.id.group == "org.lwjgl") {
            runtime "org.lwjgl:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}:${lwjglNatives}"
        }
    }*/
}

Please refer to the wiki for a more detailed guide and for other systems (such as Maven, Sbt or Leiningen).

Note: total repo size is around 24.1 MB, but there are included 22.6 MB of assets (mainly fonts), this means that the actual size is around 1.5 MB. I always thought a pairs of tens of MB is negligible, but if this is not your case, then just clone and throw away the fonts you don't need or pick up the imgui-light jar from the release page. Thanks to chrjen for that.

LibGdx

On the initiative to Catvert, ImGui plays now nice also with LibGdx.

Simply follow this short wiki on how to set it up.

Gallery

User screenshots:
Gallery Part 1 (Feb 2015 to Feb 2016)
Gallery Part 2 (Feb 2016 to Aug 2016)
Gallery Part 3 (Aug 2016 to Jan 2017)
Gallery Part 4 (Jan 2017 to Aug 2017)
Gallery Part 5 (Aug 2017 to Feb 2018)
Gallery Part 6 (Feb 2018 to June 2018)
Gallery Part 7 (June 2018 to January 2019)
Gallery Part 8 (January 2019 onward)
Also see the Mega screenshots for an idea of the available features.

Various tools screenshot game

screenshot tool

screenshot demo

screenshot profiler

ImGui supports also other languages, such as japanese or chinese, initiliazed here as:

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

or here

Font font = io.getFonts().addFontFromFileTTF("extraFonts/ArialUni.ttf", 18f, new FontConfig(), io.getFonts().getGlyphRangesJapanese());
assert (font != null);

Imgur

References

The Immediate Mode GUI paradigm may at first appear unusual to some users. This is mainly because "Retained Mode" GUIs have been so widespread and predominant. The following links can give you a better understanding about how Immediate Mode GUIs works.

See the Wiki and Bindings for third-party bindings to different languages and frameworks.

Credits

Developed by Omar Cornut and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of Media Molecule and first used internally on the game Tearaway.

Omar first discovered imgui principles at Q-Games where Atman had dropped his own simple imgui implementation in the codebase, which Omar spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When Omar moved to Media Molecule he rewrote a new library trying to overcome the flaws and limitations of the first one he's worked with. It became this library and since then he (and me) has spent an unreasonable amount of time iterating on it.

Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license).

Embeds stb_textedit.h, stb_truetype.h, stb_rectpack.h by Sean Barrett (public domain).

Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.

Ongoing native dear imgui development is financially supported on Patreon and by private sponsors (Kotlin imgui here)

Double-chocolate native sponsors:

  • Blizzard Entertainment
  • Media Molecule
  • Mobigame
  • Insomniac Games
  • Aras Pranckevičius
  • Lizardcube
  • Greggman
  • DotEmu
  • Nadeo

and many other private persons

I'm very grateful for the support of the persons that have directly contributed to this rewrite via bugs reports, bug fixes, discussions and other forms of support (in alphabetical order):

License

Dear JVM ImGui is licensed under the MIT License, see LICENSE for more information.

imgui's People

Contributors

antbern avatar bbodi avatar chrjen avatar elect86 avatar exuvo avatar h0bb3 avatar klianc09 avatar kyay10 avatar mr00anderson avatar s15n avatar sunny1337 avatar sylvyrfysh avatar tasgon avatar themrmilchmann avatar x4e avatar zeroeightysix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgui's Issues

So this crashes

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\br3nn\AppData\Local\Temp\lwjglbr3nn\3.1.7-SNAPSHOT\lwjgl.dll: Can't load IA 32-bit .dll on a Intel 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.lwjgl.system.Library.loadSystem(Library.java:162)
at org.lwjgl.system.Library.loadSystem(Library.java:152)
at org.lwjgl.system.Library.loadSystem(Library.java:116)
at org.lwjgl.system.Library.loadSystem(Library.java:67)
at org.lwjgl.system.Library.(Library.java:50)
at org.lwjgl.system.MemoryAccessJNI.(MemoryAccessJNI.java:13)
at org.lwjgl.system.Pointer.(Pointer.java:26)
at org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:80)
at org.lwjgl.glfw.GLFW.(GLFW.java:665)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
at java.lang.reflect.Field.getInt(Field.java:574)
at org.lwjgl.system.APIUtil.apiClassTokens(APIUtil.java:308)
at uno.glfw.glfw.(glfw.kt:77)
at Poop.(Poop.java:26)
at Poop.main(Poop.java:18)

Recent fat jar loads fail

I have tried building my own, and using the provided jars, but all the recent fat jars fail.
The issue is with the GLFW library, setting the uno-sdk to sha 040f71aaf6ac580925f66cb86bbb3a98d40b0646 (right before changing getTime to float) and then fixing callbacks works. I cannot seem to fix this, traces are

Exception in thread "Thread-0" java.lang.NoSuchMethodError: uno.glfw.GlfwWindow.setScrollCallBack(Lkotlin/jvm/functions/Function2;)V
	at imgui.impl.LwjglGL3.init(LwjglGL3.kt:103)

Setting init's second argument to false, therefore bypassing scrollCallback brings up

Exception in thread "Thread-0" java.lang.NoSuchMethodError: uno.glfw.glfw.getTime()F
	at imgui.impl.LwjglGL3.newFrame(LwjglGL3.kt:127)

Demo window NoSuchMethodError

Issue in commit fd68422
Tested and don't have the issue in commit 5576911

When navigating to (Widgets > Basics) in demo window I get the following error.

java.lang.NoSuchMethodError: glm_.vec2.Vec2.anyGreaterThanEqual(Lglm_/vec2/Vec2t;)Z
	at imgui.imgui.imgui_window$DefaultImpls.begin(window.kt:678)
	at imgui.ImGui.begin(imgui.kt:53)
	at imgui.Static_funcsKt.beginChildEx(static funcs.kt:772)
	at imgui.imgui.imgui_window$DefaultImpls.beginChild(window.kt:734)
	at imgui.ImGui.beginChild(imgui.kt:53)
	at imgui.imgui.imgui_utilities$DefaultImpls.beginChildFrame(utilities.kt:219)
	at imgui.ImGui.beginChildFrame(imgui.kt:53)
	at imgui.imgui.imgui_utilities$DefaultImpls.beginChildFrame$default(utilities.kt:213)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.listBoxHeader(widgets selectableLists.kt:211)
	at imgui.ImGui.listBoxHeader(imgui.kt:53)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.listBoxHeader(widgets selectableLists.kt:229)
	at imgui.ImGui.listBoxHeader(imgui.kt:53)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.listBox(widgets selectableLists.kt:166)
	at imgui.ImGui.listBox(imgui.kt:53)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:402)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:180)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:91)
	at imgui.ImGui.showDemoWindow(imgui.kt:53)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:87)
	at imgui.ImGui.showDemoWindow(imgui.kt:53)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:749)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:265)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:503)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:264)
	at java.base/java.lang.Thread.run(Thread.java:844)

Fat jar fails loading

Fat jar 1.52 works fine, but 1.53 wip beta 03 fails to load with

`[LWJGL] Version: 3.1.5 SNAPSHOT

[LWJGL] OS: Windows 10 v10.0

[LWJGL] JRE: 1.8.0_144 amd64

[LWJGL] JVM: Java HotSpot(TM) 64-Bit Server VM v25.144-b01 by Oracle Corporation

[LWJGL] Loading library (system): lwjgl

[LWJGL] lwjgl.dll not found in java.library.path

[LWJGL] Failed to load a library. Possible solutions:

a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.

b) Add the JAR that contains the shared library to the classpath.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: lwjgl.dll

at org.lwjgl.system.Library.loadSystem(Library.java:146)

at org.lwjgl.system.Library.loadSystem(Library.java:66)

at org.lwjgl.system.Library.<clinit>(Library.java:49)

at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:60)

at uno.buffer.BufferKt.intBufferBig(buffer.kt:21)

at imgui.impl.LwjglGL3.<clinit>(LwjglGL3.kt:63)

at com.sylvyrfysh.monerowallet.MoneroWalletMain.<init>(MoneroWalletMain.java:23)

at com.sylvyrfysh.monerowallet.MoneroWalletMain.main(MoneroWalletMain.java:18)

`

Is LWJGL a required dependency?

Hi,
im currently in the progress of writing a binding for JME3. I noticed, that upon creating the Font
fontTexture = IO.INSTANCE.getFonts().getTexDataAsRGBA32();
I get an expection:

java.lang.NoClassDefFoundError: org/lwjgl/system/MemoryUtil
	at uno.buffer.BufferKt.bufferBig(buffer.kt:18)
	at imgui.FontAtlas.addFontFromMemoryTTF(font.kt:160)
	at imgui.FontAtlas.addFontFromMemoryCompressedTTF(font.kt:176)
	at imgui.FontAtlas.addFontFromMemoryCompressedBase85TTF(font.kt:185)
	at imgui.FontAtlas.addFontDefault(font.kt:147)
	at imgui.FontAtlas.addFontDefault(font.kt:138)
	at imgui.FontAtlas.getTexDataAsAlpha8(font.kt:242)
	at imgui.FontAtlas.getTexDataAsRGBA32(font.kt:253)
	at ImGuiState.initialize(ImGuiState.java:25)
	at com.jme3.app.state.BaseAppState.initialize(BaseAppState.java:124)
	at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:236)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
	at java.lang.Thread.run(Thread.java:812)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.system.MemoryUtil
	at java.net.URLClassLoader.findClass(URLClassLoader.java:444)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:490)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:376)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
	... 17 more

So the question is, is lwjgl required for this?
Or is there some way I can configure the system to use a different buffer implementation?
Reason is, that I try to only use the official JME3 api for the binding in the hope that it will also work with jogl ect.
Greetings, Empire

Collapsing window issue

Hello, I have an issue when I collapse a window when i'm using functionalProgramming.window, the window disappeared and is replaced by a debug window.
I have no problem when i'm using begin() with end().

Example :

functionalProgramming.window("Test", null) {
  button("test button")
}

Using ImGui with existing lwjgl

Hello,

we have existing java framework that uses lwjgl for its rendering.
We want to create editor on top of it using imgui. But imgui also runs on lwjgl.

The only gradle dependency I have is imgui, so no lwjgl, since it is already included inside .jar of our framework.

The issue is, when I run the application, our framework initialized glfw and creates its window.
Then when I create my own new glfw window and call lwjglGL3.newFrame(), it crashes on

Exception in thread "main" java.lang.NoSuchMethodError: org.lwjgl.opengl.GL30.glGetInteger(I)I
	at imgui.impl.LwjglGL3.createDeviceObjects(LwjglGL3.kt:210)
	at imgui.impl.LwjglGL3.newFrame(LwjglGL3.kt:103)
	at sk.greentube.DiceTimerApplet.tick(DiceTimerApplet.java:143)

which I presume is caused by mixed lwjgl versions. Could you please help me fix it? Or what dependencies should I have inside Idea so both our framework and imgui runs at the same time (same thread)

This is code snippet I use. tick() is called after our framework initializes GLFW and creates its window.

    @Override
    public void tick() {
        if(windowPointer == 0){
            GLFW.glfwDefaultWindowHints();
            windowPointer = GLFW.glfwCreateWindow(500, 500, "IMGUI", 0, 0);
            GLFW.glfwMakeContextCurrent(windowPointer);
        }
        
        GLFW.glfwMakeContextCurrent(windowPointer);
        lwjglGL3.newFrame(); // CRASH HERE

        int backBufferTextureId = GLMain.backBufferTextureId;
        int backBuffer = GLMain.backBuffer;
        imgui.text("Novo back buffer: " + backBuffer);
        imgui.text("Novo Pointer: " + backBufferTextureId);
        imgui.text("ImGui Pointer: " + windowPointer);
        imgui.image(backBufferTextureId, new Vec2(300, 300), new Vec2(0, 0), new Vec2(1, 1), new Vec4(1, 1, 1, 1), new Vec4(1, 1, 1, 1));


        gln.GlnKt.glViewport(500, 500);
        gln.GlnKt.glClearColor(new Vec4(0.45f, 0.55f, 0.6f, 1f));
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        imgui.render();
        lwjglGL3.renderDrawData(imgui.getDrawData());

        glfwSwapBuffers(windowPointer);
    }

Thank you

LibGDX example not working

Hi, I'd like to use imgui with LibGDX, but couldn't find any minimal example. And the current steps in the Wiki do not work for me.

My current code is in this repository (and I'd like to be able to provide a working minimal example project for others too):
https://github.com/klianc09/imguiexample

I added the dependencies to the generated project, as documented in the Wiki.
However when trying to run I get the following error message:

$ ./gradlew lwjgl3:run
Configuration on demand is an incubating feature.
Download https://jitpack.io/com/github/kotlin-graphics/imgui/-SNAPSHOT/maven-metadata.xml

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':core:compileClasspath'.
> Could not find com.github.kotlin-graphics:imgui:-SNAPSHOT.
  Searched in the following locations:
  file:/home/toni/.m2/repository/com/github/kotlin-graphics/imgui/-SNAPSHOT/maven-metadata.xml
  file:/home/toni/.m2/repository/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.pom
  file:/home/toni/.m2/repository/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.jar
  https://repo1.maven.org/maven2/com/github/kotlin-graphics/imgui/-SNAPSHOT/maven-metadata.xml
  https://repo1.maven.org/maven2/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.pom
  https://repo1.maven.org/maven2/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.jar
  https://jcenter.bintray.com/com/github/kotlin-graphics/imgui/-SNAPSHOT/maven-metadata.xml
  https://jcenter.bintray.com/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.pom
  https://jcenter.bintray.com/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.jar
  https://oss.sonatype.org/content/repositories/snapshots/com/github/kotlin-graphics/imgui/-SNAPSHOT/maven-metadata.xml
  https://oss.sonatype.org/content/repositories/snapshots/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.pom
  https://oss.sonatype.org/content/repositories/snapshots/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.jar
  https://jitpack.io/com/github/kotlin-graphics/imgui/-SNAPSHOT/maven-metadata.xml
  https://jitpack.io/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--v1.60wip-beta-02-g789514e-20.pom
  https://jitpack.io/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--v1.60wip-beta-02-g789514e-20.jar
  https://dl.bintray.com/kotlin/kotlin-dev/com/github/kotlin-graphics/imgui/-SNAPSHOT/maven-metadata.xml
  https://dl.bintray.com/kotlin/kotlin-dev/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.pom
  https://dl.bintray.com/kotlin/kotlin-dev/com/github/kotlin-graphics/imgui/-SNAPSHOT/imgui--SNAPSHOT.jar
Required by:
  project :core

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 16s
1 actionable task: 1 executed

Any pointers would be appreciated.

Is it possible to use BooleanArray in checkbox ?

I would like to generate a checkbox with enum class:

enum class Enum1 { E1, E2, E3 }
val enum1ArrayEnabled = BooleanArray(Enum1.values().size)

with (imGui) {
  Enum1.values().forEachIndexed { index, value ->
    checkbox(value.name, ::enum1ArrayEnabled[index])
  }
}

::enum1ArrayEnabled[index] does not compile, maybe there is another way to do so...

Regards.

Reduce number of dependencies

Hello,

I'm questioning about how to reduce the size of my build, and now I'm looking about this imgui port. I use it with vulkan, so I have to call getDrawData(), and make the draw myself.

In my context, is that possible to reduce the number of dependencies ? Maybe I don't really need all the LWJGL-3.1.7-SNAPSHOT stuff needed by imgui.

Extra fonts & issue with lwjgl-stb natives

There seems to be two copies of the fonts in the -SNAPSHOT version. See here: https://i.imgur.com/34H4lWg.png

And ArialUni takes up 22MB! I was wondering why my jar file was so big. This is easily removed but I think you could get rid of it

On another note:

I also ran into a problem getting it to work on windows with LWJGL-3.1.7-SNAPSHOT(using libgdx 1.9.8). It could not find the native windows files for lwjgl-stb. It only exists up to 3.1.6 on the maven repository.. but strangely there is a linux natives for 3.1.7. I had to use the 3.1.6 stb version which gives a warning on startup but it seems to be working now.

JME3: Init

So I finally managed to get the dependencies working proerply in combination with jme3 :)

	@Override
	protected void initialize(Application app) {
		this.rendererapp = app;
		ImGui.INSTANCE.initialize();
		fontTexture = IO.INSTANCE.getFonts().getTexDataAsRGBA32();
                //TODO pack into jme texture and upload after this
	}

I try to roughly follow the generic lwjgl3 binding already provided, but bring it into a jme appstate.
Am I missing some other required call in before?

I get some kind of assertion from the depth of the font system, sadly I do not really understand the reason for this:

fontAtlas.class@461
    fun addCustomRectRegular(id: Int, width: Int, height: Int): Int {
        assert(id >= 0x10000 && width in 0..0xFFFF && height in 0..0xFFFF)
        val r = CustomRect()
        r.id = id
        r.width = width
        r.height = height
        customRects.add(r)
        return customRects.lastIndex
    }

width is 181, height is 27, but id is -2147483648.
The call comes from here:

    fun buildRegisterDefaultCustomRects() {
        if (customRectIds[0] < 0)
            customRectIds[0] = addCustomRectRegular(DefaultTexData.id, DefaultTexData.wHalf * 2 + 1, DefaultTexData.h)
    }

Sadly I'm missing kotlin knowledge & ide support support a bit, and cannot figure out why the id has that value (or where it actually comes from)

MemoryStack leak in v1.6.3-beta-02

The thread local MemoryStack is leaking frames and leads to an OutOfMemoryError. This isn't present in v1.6.3-beta-01.

Reproduce when running the LWJGL example by printing MemoryStack.stackGet().pointer in the main loop - on beta-01 this remains constant (as it should) but on beta-02 falls to 0 and crashes.

Corrupted cursor graphics

Issue in commit 0b12a2e

Using the built-in cursor by calling io.setMouseDrawCursor(true) now displays a cursor with corrupted graphics.

This did not happen in the previous version I tested, v1.62-beta-02.

cursor-issue

kotlin.NotImplementedError: An operation is not implemented.

Hello,

I got a recurring error when I use the colorButton: If I drag and drop (in fact if I move too fast when I click, whatever) it, I will got the following exception:

Exception in thread "main" kotlin.NotImplementedError: An operation is not implemented.
	at imgui.imgui.imgui_dragAndDrop$DefaultImpls.setDragDropPayload(drag & Drop.kt:126)
	at imgui.ImGui.setDragDropPayload(imgui.kt:45)
	at imgui.imgui.imgui_widgetsColorEditorPicker$DefaultImpls.colorButton(widgets colorEditorPicker.kt:646)
	at imgui.ImGui.colorButton(imgui.kt:45)
	at org.sheepy.vulkan.sand.graphics.SandUIDescriptor.newFrame(SandUIDescriptor.java:110)
	at org.sheepy.vulkan.imgui.ImGuiPipeline.newFrame(ImGuiPipeline.java:377)
	at org.sheepy.vulkan.sand.pipelinepool.RenderPipelinePool.execute(RenderPipelinePool.java:74)
	at org.sheepy.vulkan.sand.SandApplication.drawFrame(SandApplication.java:169)
	at org.sheepy.vulkan.VulkanApplication.mainLoop(VulkanApplication.java:125)
	at org.sheepy.vulkan.sand.SandApplication.mainLoop(SandApplication.java:128)
	at org.sheepy.vulkan.VulkanApplication.run(VulkanApplication.java:63)
	at org.sheepy.vulkan.sand.SandApplication.main(SandApplication.java:178)

Not a big problem, I just open an issue to track it.

I use the last Snapshot "v1.62-beta-02".

Crash on color picker

When opening color picker and right-mouse clicking into color area to change "color pick mode", the application crashes on

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at imgui.imgui.imgui_widgetsColorEditorPicker$DefaultImpls.colorPicker4(widgets colorEditorPicker.kt:334)
	at imgui.ImGui.colorPicker4(imgui.kt:44)
	at imgui.imgui.imgui_widgetsColorEditorPicker$DefaultImpls.colorPicker4$default(widgets colorEditorPicker.kt:299)
	at imgui.imgui.imgui_widgetsText$Companion.colorPickerOptionsPopup(widgets text.kt:266)
	at imgui.imgui.imgui_widgetsColorEditorPicker$DefaultImpls.colorPicker4(widgets colorEditorPicker.kt:313)
	at imgui.ImGui.colorPicker4(imgui.kt:44)
	at imgui.imgui.imgui_widgetsColorEditorPicker$DefaultImpls.colorEdit4(widgets colorEditorPicker.kt:217)
	at imgui.ImGui.colorEdit4(imgui.kt:44)
	at imgui.imgui.imgui_widgetsColorEditorPicker$DefaultImpls.colorEdit4(widgets colorEditorPicker.kt:99)

Multiple font size

Hi !
How can i handle multiple font size ? I tried to load 2 fonts from the same TTF and with a different pixels size but it crash immediatly without any stacktrace but with exit code -1073740940 (0xC0000374).

I used this code to load fonts

var fontBytes = Constants.imguiFontPath.readBytes()
imguiDefaultFont = imgui.IO.fonts.addFontFromMemoryTTF(CharArray(fontBytes.size, { fontBytes[it].c }), 19f, FontConfig(), glyphRanges = imgui.IO.fonts.glyphRangesDefault)
imguiBigFont = imgui.IO.fonts.addFontFromMemoryTTF(CharArray(fontBytes.size, { fontBytes[it].c }),  30f, FontConfig(), glyphRanges = imgui.IO.fonts.glyphRangesDefault)

Is there any solution to have multiple font size with just one font ?
Thanks, Catvert.

Stable branch of Kotlin support

It seems this is dependent on a future and/or experimental version of Kotlin in the 1.2 branch leading to gradle import failure, if used in a non-experimental project.

Warning:<i><b>project ':core': Unable to build Kotlin project configuration</b> Details: java.lang.reflect.InvocationTargetException: null Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':core:compileClasspath'. Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find org.jetbrains.kotlin:kotlin-stdlib:1.2.0-beta-88.

Current version of Kotlin as of Nov 6, 2017 is 1.1.51

Is there any way to get around this without having to fork it?

renderer bug

Hi !
Since last commits (up feb 11-13-18), imgui doesn't render at all (with lwjgl3 at least) ! UI components are present but not displayed.

java.lang.NullPointerException

After some days of porting my application to the latest LWJGL version, I tried to use Dear ImGui with it.
I got a bit confused since in the readme it says you only have to initialize elements and render them, but in the tests of the wiki you are using your own GlfwWindow, and this makes it hard for me since I need a way to port my original glfw window, as a long, to the GlfwWindow.

My code is here:

@Override
 public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        ImGui.INSTANCE.newFrame();

        float[] f = {0f};
        int[] i = {0};

        ImGui.INSTANCE.text("Hello, world %d", 123);

        if (ImGui.INSTANCE.button("OK", new Vec2(20, 20))) {
            System.out.println("OK Button Pressed!");
        }

        ImGui.INSTANCE.sliderFloat("float", f, 0f, 1f, "display format", 0.5f);
        ImGui.INSTANCE.sliderInt("int", i, 0, 100, "display format");

        ImGui.INSTANCE.render();
    }

The exception being thrown is here:

java.lang.NullPointerException: Rendering screen
	at imgui.ImguiKt.getG(imgui.kt:22)
	at imgui.imgui.imgui_main$DefaultImpls.newFrame(main.kt:47)
	at imgui.ImGui.newFrame(imgui.kt:44)
	at <REDACTED>.ClickGUIScreen.drawScreen(ClickGUIScreen.java:61)

switch fullscreen/window mode crash imgui

Hi !
When I switch the game to full screen in game, imgui crash with this error:
Exception in thread "main" kotlin.KotlinNullPointerException at imgui.imgui.imgui_internal$DefaultImpls.getCurrentWindow(internal.kt:105) at imgui.ImGui.getCurrentWindow(imgui.kt:27) at imgui.imgui.imgui_parametersStacks$DefaultImpls.popItemWidth(parameters stacks.kt:230) at imgui.ImGui.popItemWidth(imgui.kt:27) at be.catvert.pc.scenes.MainMenuScene$drawSettingsWindow$$inlined$with$lambda$1.invoke(MainMenuScene.kt:257) at be.catvert.pc.scenes.MainMenuScene$drawSettingsWindow$$inlined$with$lambda$1.invoke(MainMenuScene.kt:26) at be.catvert.pc.utility.ImGuiHelper.withCenteredWindow(ImGuiHelper.kt:381) at be.catvert.pc.utility.ImGuiHelper.withCenteredWindow$default(ImGuiHelper.kt:377) at be.catvert.pc.scenes.MainMenuScene.drawSettingsWindow(MainMenuScene.kt:192) at be.catvert.pc.scenes.MainMenuScene.drawUI(MainMenuScene.kt:54) at be.catvert.pc.scenes.MainMenuScene.render(MainMenuScene.kt:42) at be.catvert.pc.scenes.SceneManager.render(SceneManager.kt:96) at be.catvert.pc.PCGame.render(PCGame.kt:101) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:392) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:137) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:111) at be.catvert.pc.Lwjgl3Launcher.main(Lwjgl3Launcher.kt:34)

I tried several solutions to fix the problem, like relaunching a new frame, end the window before the switch, ... but nothing works: (

Crashes in style editor

This is using v1.62-beta-02.

In the demo window if you go (Help > Style Editor > Rendering) then click and drag the Curve Tesselation Tolerance button I crash with the following exception.

Exception in thread "hmd-renderer" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:44)
	at java.base/java.lang.String.charAt(String.java:704)
	at imgui.imgui.imgui_internal$DefaultImpls.parseFormatFindStart(internal.kt:3283)
	at imgui.ImGui.parseFormatFindStart(imgui.kt:45)
	at imgui.imgui.imgui_internal$Companion.roundScalarWithFormat(internal.kt:3459)
	at imgui.imgui.imgui_main$Companion.dragBehaviorT(main.kt:862)
	at imgui.imgui.imgui_internal$DefaultImpls.dragBehavior(internal.kt:1509)
	at imgui.ImGui.dragBehavior(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar(widgets drags.kt:266)
	at imgui.ImGui.dragScalar(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragFloat(widgets drags.kt:58)
	at imgui.ImGui.dragFloat(imgui.kt:45)
	at imgui.imgui.demo.StyleEditor.invoke(ExampleApp.kt:1138)
	at imgui.imgui.demo.StyleEditor.invoke$default(ExampleApp.kt:1090)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:155)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:89)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:85)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:743)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:260)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:492)

Likewise if you go (Help > Style Editor > Fonts > Glyphs) I crash with get he following exception.

Exception in thread "hmd-renderer" java.lang.IndexOutOfBoundsException: Index -1 out-of-bounds for length 225
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:372)
	at java.base/java.util.ArrayList.get(ArrayList.java:440)
	at imgui.Font.findGlyphNoFallback(font.kt:978)
	at imgui.Font.findGlyphNoFallback(font.kt:977)
	at imgui.imgui.demo.StyleEditor.invoke(ExampleApp.kt:1275)
	at imgui.imgui.demo.StyleEditor.invoke$default(ExampleApp.kt:1090)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:155)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:89)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:85)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:743)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:260)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:492)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:259)
	at java.base/java.lang.Thread.run(Thread.java:844)

ImGui with Libgdx on Mac OS X

I'm going to build an editor for my game on Libgdx and found that imgui can help a lot in that.
My game is targeting Open GL ES 2.0 devices (including mobile phones). The editor should be able to run on Mac OS X and Windows.
I was able to run Lwjgl3 implementation of ImGui together with a simple libgdx project after several hours of trials and errors, but I see which troubles will I meet, when I try to integrate ImGui into existing project.

Points:

  1. Current ImGui implementation is based on GL3.
  2. That means that I have to configure Lwjgl to use OpenGL 3.2 API
  3. Once I configure it to use OpenGL 3.2 on Mac OS X, there seems to be no way to use earlier versions of OpenGL.
  4. Shader of LibGDX/SpriteBatch is not compatible with OpenGL 3.2 API (I had to rewrite it to use 'in' and 'out' instead of 'attribute' and 'varying')
  5. I have custom shaders in my game and they are targeting OpenGL ES 2.0. That means I can't test my shaders in the editor (and I have to find workarounds, like automatically rewrite old shaders to use in/out, when I run it on desktop)
  6. All that means that I can't use OpenGL 3.2 API and have to stick to OpenGL 2.0 API.
  7. As I can see it is big stop for LibGDX users (probably the largest set of potential users of ImGui)

Questions:

  1. Do I miss something?
  2. If I don't miss, is it a lot of work to add an implementation for OpenGL 2.0 in ImGui?

Problem with IDs and imageButtons

Hi !

I've found an issue when I use a lot of imageButtons. The program don't crash but imageButtons (the latter, I assume greater than 256 or 512) become unresponsive to the click (and only imageButtons, other elements are responsive as well). The problem is propagated to all windows on the screen having imageButtons.

Thanks for your help,
Catvert.

demos or examples?

Can you please provide some demos or samples so I can use imgui with kotlin?

Thank you!

inputText issues

Report will use example as reference.

static char[][] buf=new char[3][255];
boolean[] windowOpen=new boolean[1];

private void init() {
	buf[0][0]='a';
}

public void loop(){
	glfw.pollEvents();
	lwjglGL3.newFrame();
	float w=window.getFramebufferSize().x,h=window.getFramebufferSize().y;
	imgui.setNextWindowPos(new Vec2((w-350)/2,(h-350)/2), Cond.FirstUseEver, new Vec2());
	imgui.setNextWindowSize(new Vec2(350,350), Cond.FirstUseEver);
	if(imgui.begin("Test", windowOpen, 0)) {
		imgui.text("Test");
		for(int i=0;i<buf.length;i++) {
			imgui.text(String.valueOf(i));
			imgui.inputText("", buf[i], InputTextFlags.EnterReturnsTrue.getI());
		}
		imgui.end();
	}
	gln.GlnKt.glViewport(window.getFramebufferSize());
	gln.GlnKt.glClearColor(new Vec4(.8));
	GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

	imgui.render();
	window.swapBuffers();
}

When using multiple inputTexts, clicking on one (e.g. 0) immediately copies data to the next array in buf (e.g. 1). It does not touch buf[2]. The text boxes cannot be modified, as the cursor does not stay in them long enough to grab a character. Clicking on the last box (e.g. buf[2]) selects all boxes, copies that value to them, and works to edit text, but for all boxes at one.

Side note: this still happens if buffers are not in a large array, they could be buffer[], james[], and monero[] and this still happens.

dragVec3 receiving Vec2 as parameter

Hello,

I'm starting use imgui to test my graphic framework with LWJGL, OpenGL, GLFW...

When I got something working I realized the function dragVec3 seemes to be wrong.

It receiving a Vec2 instead a Vec3.

The Vec3i is correct, I'm using it for now... but I would like ask you to check it.

Thank you.

Image uv

Hi ! I have a little problem, I don't know how to calculate uv0 and uv1 when displaying an image. I've managed to bind a texture with libGDX correctly but I don't understand how uv0 and uv1 work and I think that's why imgui shows me a black image. Thanks to you, Catvert

Crash in vertical sliders in demo window

This is using v1.62-beta-02.

In the demo window if I go (Widgets > Vertical Sliders) and try to move any of the sliders I get the following exception.

Exception in thread "hmd-renderer" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:44)
	at java.base/java.lang.String.charAt(String.java:704)
	at imgui.imgui.imgui_internal$DefaultImpls.parseFormatFindStart(internal.kt:3283)
	at imgui.ImGui.parseFormatFindStart(imgui.kt:45)
	at imgui.imgui.imgui_internal$Companion.roundScalarWithFormat(internal.kt:3459)
	at imgui.imgui.imgui_internal$DefaultImpls.sliderBehaviorT(internal.kt:1972)
	at imgui.ImGui.sliderBehaviorT(imgui.kt:45)
	at imgui.imgui.imgui_internal$DefaultImpls.sliderBehavior(internal.kt:1548)
	at imgui.ImGui.sliderBehavior(imgui.kt:45)
	at imgui.imgui.imgui_widgetsSliders$DefaultImpls.vSliderScalar(widgets sliders.kt:258)
	at imgui.ImGui.vSliderScalar(imgui.kt:45)
	at imgui.imgui.imgui_widgetsSliders$DefaultImpls.vSliderFloat(widgets sliders.kt:221)
	at imgui.ImGui.vSliderFloat(imgui.kt:45)
	at imgui.imgui.imgui_widgetsSliders$DefaultImpls.vSliderFloat$default(widgets sliders.kt:220)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:987)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:241)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:89)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:85)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:748)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:260)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:492)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:259)
	at java.base/java.lang.Thread.run(Thread.java:844)

Crash while navigating metrics in demo window

Issue in commit f95d10c

Go to (Help > Metrics > Internal State) then either scroll to the bottom or resize the window to see the bottom of Internal State. Doing so gives the following exception.

java.lang.IndexOutOfBoundsException: Index -1 out-of-bounds for length 225
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:372)
	at java.base/java.util.ArrayList.get(ArrayList.java:440)
	at imgui.Font.findGlyph(font.kt:992)
	at imgui.Font.findGlyph(font.kt:991)
	at imgui.Font.renderText(font.kt:1288)
	at imgui.DrawList.addText(draw.kt:325)
	at imgui.DrawList.addText$default(draw.kt:300)
	at imgui.imgui.imgui_internal$DefaultImpls.renderTextWrapped(internal.kt:1056)
	at imgui.ImGui.renderTextWrapped(imgui.kt:45)
	at imgui.imgui.imgui_widgetsText$DefaultImpls.textUnformatted(widgets text.kt:124)
	at imgui.ImGui.textUnformatted(imgui.kt:45)
	at imgui.imgui.imgui_widgetsText$DefaultImpls.textV(widgets text.kt:138)
	at imgui.ImGui.textV(imgui.kt:45)
	at imgui.imgui.imgui_widgetsText$DefaultImpls.text(widgets text.kt:128)
	at imgui.ImGui.text(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showMetricsWindow(demo debug informations.kt:136)
	at imgui.ImGui.showMetricsWindow(imgui.kt:45)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:84)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:91)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:87)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:750)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:271)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:503)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:270)
	at java.base/java.lang.Thread.run(Thread.java:844)

Max ids

Hi !
I have a problem when I have more than 512 ids used in the same time.
I've got this when I for example draw 2 windows that need to draw a lot of image buttons.

Example :
capture du 2018-01-27 17-17-03

The stacktrace :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 512
at imgui.internal.Window.getId(classes.kt:560)
at imgui.imgui.imgui_idScopes$DefaultImpls.pushId(id scopes.kt:19)
at imgui.ImGui.pushId(imgui.kt:27)
at imgui.imgui.imgui_widgetsMain$DefaultImpls.imageButton(widgets main.kt:103)
at imgui.ImGui.imageButton(imgui.kt:27)
at imgui.imgui.imgui_widgetsMain$DefaultImpls.imageButton$default(widgets main.kt:96)

Why not use a dynamic list instead of a fixed array?
Thanks, Catvert.

Crash on sliders with units

Issue #47 not fixed in commit 0b12a2e

(Widgets > Range WIdgets)
Exception in thread "hmd-renderer" java.lang.NumberFormatException: For input string: "1010 units"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at glm_.ExtensionsKt.getI(extensions.kt:210)
	at imgui.imgui.imgui_internal$Companion.roundScalarWithFormat(internal.kt:3497)
	at imgui.imgui.imgui_main$Companion.dragBehaviorT(main.kt:658)
	at imgui.imgui.imgui_internal$DefaultImpls.dragBehavior(internal.kt:1551)
	at imgui.ImGui.dragBehavior(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar(widgets drags.kt:266)
	at imgui.ImGui.dragScalar(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar$default(widgets drags.kt:212)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragInt(widgets drags.kt:133)
	at imgui.ImGui.dragInt(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragIntRange2(widgets drags.kt:184)
	at imgui.ImGui.dragIntRange2(imgui.kt:45)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:877)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:180)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:91)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:87)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:825)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:263)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:503)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:262)
	at java.base/java.lang.Thread.run(Thread.java:844)

(Widgets > Basics)
Exception in thread "hmd-renderer" java.lang.NumberFormatException: For input string: "44%"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at glm_.ExtensionsKt.getI(extensions.kt:210)
	at imgui.imgui.imgui_internal$Companion.roundScalarWithFormat(internal.kt:3497)
	at imgui.imgui.imgui_main$Companion.dragBehaviorT(main.kt:658)
	at imgui.imgui.imgui_internal$DefaultImpls.dragBehavior(internal.kt:1551)
	at imgui.ImGui.dragBehavior(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar(widgets drags.kt:266)
	at imgui.ImGui.dragScalar(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar$default(widgets drags.kt:212)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragInt(widgets drags.kt:133)
	at imgui.ImGui.dragInt(imgui.kt:45)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:378)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:180)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:91)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:87)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:825)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:263)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:503)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:262)
	at java.base/java.lang.Thread.run(Thread.java:844)

NoSuchMethodError STBRPRect

Hi !
Since I refresh my gradle project, I have a NoSuchMethodError.
This is the stacktrace :
Caused by: java.lang.NoSuchMethodError: org.lwjgl.stb.STBRPRect.was_packed()I at imgui.stb.ExtensionsKt.getWasPacked(extensions.kt:14) at imgui.FontAtlas.buildPackCustomRects(font.kt:821) at imgui.FontAtlas.buildWithStbTrueType(font.kt:633) at imgui.FontAtlas.build(font.kt:243) at imgui.FontAtlas.getTexDataAsAlpha8(font.kt:252) at imgui.FontAtlas.getTexDataAsRGBA32(font.kt:262) at imgui.impl.LwjglGL3.createFontsTexture(LwjglGL3.kt:245) at imgui.impl.LwjglGL3.createDeviceObjects(LwjglGL3.kt:176) at imgui.impl.LwjglGL3.newFrame(LwjglGL3.kt:108)
Thanks, Catvert.

Conflicting dependencies when using maven ?

Hello! After a few failed attempts at getting the dependency to work, I just can't wrap my head around it. Following the instructions from the README, adding jitpack and then imgui, just appears to produce conflicts between dependencies, making the project unbuildable.

My pom.xml: https://pastebin.com/mxnCas3S
Conflicts highlighted in intelliJ:
image
Maven log when attempting to mvn install: https://pastebin.com/UKbxJXuR

My code is a simple LWJGL loop and the sample imgui (java) code provided with the README.

I attempted excluding the dependencies myself, and adding them separately after. This only resulted in my test app launching, showing a white window for roughly a second, and then closing without a stacktrace (as if System.exit(0); was called)

My apologies if I'm missing something big, or if this isn't the right place to post this.
Thanks in advance.

Max items ?

Hello, I'm trying to add a method to display a list of selectable texture in a window with imageButtons. But when there are more than 125 buttons in the window, buttons (with an index > 125) don't react to the click. I tried to use a withId (index) to make sure they have a different id but it doesn't change anything. Thanks to you, Catvert.
sans titre

Imgui should not depend on platform specifc native libraries

Currently, the generated POM lists platform specific binaries as dependency (the LWJGL linux natives to be more specific). Since in reality imgui does not depend on a single platform this is bad behavior and unnecessary noise in the dependency graph.
I suggest making those binaries test dependencies and instruct users to add the following snippet (or something similiar) to their buildscripts:

import org.gradle.internal.os.OperatingSystem

apply plugin: 'java'
apply plugin: 'kotlin'

repositories {
    mavenCentral()
    maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url 'https://jitpack.io' }
}

dependencies {
    compile 'com.github.kotlin-graphics:imgui:-SNAPSHOT'
	
    switch ( OperatingSystem.current() ) {
        case OperatingSystem.WINDOWS:
            ext.lwjglNatives = "natives-windows"
            break
        case OperatingSystem.LINUX:
            ext.lwjglNatives = "natives-linux"
            break
        case OperatingSystem.MAC_OS:
            ext.lwjglNatives = "natives-macos"
            break
    }

    // Look up which modules and versions of LWJGL are required and add setup the approriate natives.
    configurations.compile.resolvedConfiguration.getResolvedArtifacts().forEach {
        if (it.moduleVersion.id.group == "org.lwjgl") {
            runtime "org.lwjgl:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}:${lwjglNatives}"
        }
    }
}

Shader loading fails when using a jar version of the library

I get an exception in Program.kt around line 294:
val lines = File(url.toURI()).readLines()

Looking at the url it looks like:

jar:file:/C:/Users/<myusername>/.m2/repository/com/github/kotlin-graphics/imgui/-v1.51-gfcc47f9-11/imgui--v1.51-gfcc47f9-11.jar!/shader.vert

It might be an issue exposed when grabbing imgui as a jar file from maven rather than referring directly to the code. It seems Files can't be created from a path pointing into a jar.
Using url.openStream() seem to solve this in my local tests (I don't have an environment allowing me to rebuild the imgui sources at this point so I have not tried it on the imgui code)

Are 1.5 shaders possible ?

Hi,

So my old mac book does not support the current shaders. I get the following error :

Compiler failure in shader.vert shader: ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:9: 'layout' : syntax error: syntax error

This is strange because Apple claims it support OpenGl 3.3. The reported version is "3.3.0 Cocoa NSGL dynamic".

I don't know anything about shaders, but they look sufficiently simple for me to think that it might be possible to convert them to 1.5.

What do you think ?

Regards,

Julien

Crash on sliders sliding into the negative

Found in commit 297e44d
Related to #47 #48

Every time a slider has a negative value the following exception happens.

(Widgets > Basics)
Exception in thread "hmd-renderer" java.text.ParseException: Unparseable number: "-2%"
	at java.base/java.text.NumberFormat.parse(NumberFormat.java:393)
	at imgui.imgui.imgui_internal$Companion.roundScalarWithFormat(internal.kt:3498)
	at imgui.imgui.imgui_main$Companion.dragBehaviorT(main.kt:658)
	at imgui.imgui.imgui_internal$DefaultImpls.dragBehavior(internal.kt:1552)
	at imgui.ImGui.dragBehavior(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar(widgets drags.kt:266)
	at imgui.ImGui.dragScalar(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar$default(widgets drags.kt:212)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragInt(widgets drags.kt:133)
	at imgui.ImGui.dragInt(imgui.kt:45)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:378)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:180)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:91)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:87)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:748)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:270)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:503)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:269)
	at java.base/java.lang.Thread.run(Thread.java:844)

This happens for every slider I tried that allows me to slide the value into the negative.

DEMO EXCEPTION: Unparseable number: "-0.0004"
DEMO EXCEPTION: Unparseable number: "-59 deg"
DEMO EXCEPTION: Unparseable number: "-0.008700 ns"
DEMO EXCEPTION: Unparseable number: "-425 units"
DEMO EXCEPTION: Unparseable number: "-60"

Docking windows

Would be nice to be able to dock windows (attaching one window to another), being able to drag windows to create tabs so the user can modify the UI as he pleases.

Something like: ocornut/imgui#970

But adding the possibility to attach a window to the left/top/right/down side so it will also resize when the windows application is resized.

Using libGDX

Hi, I can't find a way to make this library work with libGDX (which also allows to use LWGL3).
Thank you for your help.

Going to remove jogamp backend

As titled, I'm planning to remove the jogamp (GL3 and VR) backend in the short future because I won't need it anymore

This will allow to focus my efforts on lwjgl backends and reduce the dependency list and in turn also the build size..

If anyone is still relying/using that, please step in

Crash on sliders with units

This is using v1.62-beta-02.

In the demo window if I go e.g. (Widgets > Range WIdgets) or (Widgets > Basics) and try to move any of the sliders with text after the number I get the following exception.

Exception in thread "hmd-renderer" java.lang.NumberFormatException: For input string: "0.006700 ns"
	at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
	at java.base/jdk.internal.math.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
	at java.base/java.lang.Float.parseFloat(Float.java:455)
	at glm_.ExtensionsKt.getF(extensions.kt:207)
	at imgui.imgui.imgui_internal$Companion.roundScalarWithFormat(internal.kt:3463)
	at imgui.imgui.imgui_main$Companion.dragBehaviorT(main.kt:862)
	at imgui.imgui.imgui_internal$DefaultImpls.dragBehavior(internal.kt:1509)
	at imgui.ImGui.dragBehavior(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragScalar(widgets drags.kt:266)
	at imgui.ImGui.dragScalar(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragFloat(widgets drags.kt:58)
	at imgui.ImGui.dragFloat(imgui.kt:45)
	at imgui.imgui.imgui_widgetsDrag$DefaultImpls.dragFloat$default(widgets drags.kt:57)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:351)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:241)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:89)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at imgui.imgui.imgui_demoDebugInformations$DefaultImpls.showDemoWindow(demo debug informations.kt:85)
	at imgui.ImGui.showDemoWindow(imgui.kt:45)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.loop(VRScene.java:748)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.lambda$run$0(VRScene.java:260)
	at uno.glfw.GlfwWindow.loop(GlfwWindow.kt:492)
	at com.chrjen.pluto.gui.VRScene$VRRenderer.run(VRScene.java:259)
	at java.base/java.lang.Thread.run(Thread.java:844)

LWJGL Test program fails from jar

Upon running the LWJGL test program from the provided jar, this exception occurs

Exception in thread "main" java.lang.IllegalArgumentException: URI is not hierarchical
at java.io.File.(Unknown Source)
at gln.program.Program.createShader(program.kt:173)
at gln.program.Program.(program.kt:100)
at imgui.impl.LwjglGL3$ProgramA.(LwjglGL3.kt:234)
at imgui.impl.LwjglGL3.createDeviceObjects(LwjglGL3.kt:159)
at imgui.impl.LwjglGL3.newFrame(LwjglGL3.kt:108)
at s.TTest.loop(TTest.java:95)
at s.TTest.run(TTest.java:53)
at s.TTest.main(TTest.java:17)

Still a gradle noob, got the stuff to download but imports not showing up. This came up, looks like a GLN issue, but wasn't sure if it was your implementation or not. Let me know!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.