kotlin-graphics/imgui

Conflicting dependencies when using maven ?

Closed this issue · 31 comments

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.

Uh, forgot to add dependencies for kotlin >.>

Thanks for pointing that out!

You should modify your build.gradle as follow:

buildscript {
   ext.kotlin_version = '1.2.0-rc-39'
   repositories {
       maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
   }
   dependencies {
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

apply plugin: "kotlin"

dependencies {
   compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
   maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
}

Let me know if that works :)

Sorry, you said Maven, I read Gradle..

Follow this link: https://kotlinlang.org/docs/reference/using-maven.html

and then:

In Maven/Gradle: Add http://dl.bintray.com/kotlin/kotlin-eap-1.2 as a repository for the build script and your projects; use 1.2.0-rc-39 as the version number for the compiler plugin and the standard library.

That.. sort of worked? IntelliJ still spits out some errors regarding the dependencies:
image
I had to download some natives for LWJGL (which I did from https://www.lwjgl.org/browse (3.1.4)), though LWJGL will produce an error about incompatible java and native library versions:

[LWJGL] [ERROR] Incompatible Java and native library versions detected.
Possible reasons:
	a) -Djava.library.path is set to a folder containing shared libraries of an older LWJGL version.
	b) The classpath contains jar files of an older LWJGL version.
Possible solutions:
	a) Make sure to not set -Djava.library.path (it is not needed for developing with LWJGL 3) or make
	   sure the folder it points to contains the shared libraries of the correct LWJGL version.
	b) Check the classpath and make sure to only have jar files of the same LWJGL version in it.

And to top it all off, since LWJGL won't exit after above errors (which I get 3 of, for each library glfw.dll, lwjgl.dll and lwjgl_opengl.dll)

I'll get this error which does appear fatal:

Exception in thread "main" java.lang.IllegalArgumentException: URI is not hierarchical
	at java.io.File.<init>(File.java:418)
	at uno.glsl.Program.createShader(Program.kt:294)
	at uno.glsl.Program.<init>(Program.kt:221)
	at imgui.impl.LwjglGL3$ProgramA.<init>(LwjglGL3.kt:223)
	at imgui.impl.LwjglGL3.createDeviceObjects(LwjglGL3.kt:148)
	at imgui.impl.LwjglGL3.newFrame(LwjglGL3.kt:97)
...

edit: my new pom.xml: https://pastebin.com/3G9hgZ6B

Thanks in advance.

Yep, I know that fatal error (getSystemResource() doesnt work with jars, should use getSystemResourceAsStream() instead).

It's been solved in the current version 1.53 WIP, 1.52 still has it

Could you just try to fetch imgui by commit (use 07fd031f52 instead 1.52)? If then it works I'm gonna dispatch a new release to fix that

Yup, all is working now! However, is there still a problem on my end, or is your imgui fork still very unstable? After fiddling around with windows from the test code, I found a number of problems. (But way too many to write all down!) Here's the first few:

Imgui Demo Window
Widgets
Basic
Expanding "Basic" causes an error:
Exception in thread "main" java.lang.Error
	at imgui.imgui.imgui_parametersStacks$DefaultImpls.pushStyleVar(parametersStacks.kt:113)
	at imgui.ImGui.pushStyleVar(imgui.kt:29)
	at imgui.imgui.imgui_utilities$DefaultImpls.beginChildFrame(utilities.kt:189)
	at imgui.ImGui.beginChildFrame(imgui.kt:29)
	at imgui.imgui.imgui_utilities$DefaultImpls.beginChildFrame$default(utilities.kt:186)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.listBoxHeader(widgetsSelectableLists.kt:196)
	at imgui.ImGui.listBoxHeader(imgui.kt:29)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.listBoxHeader(widgetsSelectableLists.kt:214)
	at imgui.ImGui.listBoxHeader(imgui.kt:29)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.listBox(widgetsSelectableLists.kt:152)
	at imgui.ImGui.listBox(imgui.kt:29)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.listBox(widgetsSelectableLists.kt:141)
	at imgui.ImGui.listBox(imgui.kt:29)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:318)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:231)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:79)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:75)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
Text > UTF-8 text
This text doesn't look very japanese AND Attempting to click the textbox causes an error:
Exception in thread "main" kotlin.NotImplementedError: An operation is not implemented.
	at imgui.TextEditState.layout(TextEditState.kt:87)
	at imgui.TextEditState.locateCoord(TextEditState.kt:428)
	at imgui.TextEditState.click(TextEditState.kt:470)
	at imgui.imgui.imgui_internal$DefaultImpls.inputTextEx(internal.kt:1520)
	at imgui.ImGui.inputTextEx(imgui.kt:29)
	at imgui.imgui.imgui_widgetsInputKeyboard$DefaultImpls.inputText(widgetsInputKeyboard.kt:30)
	at imgui.ImGui.inputText(imgui.kt:29)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:446)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:231)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:79)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:75)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
Selectables
Rendering more text into the same block Attempting to expand Rendering more text into the same block causes an error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.selectable(widgetsSelectableLists.kt:126)
	at imgui.ImGui.selectable(imgui.kt:29)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.selectable$default(widgetsSelectableLists.kt:125)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:504)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:231)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:79)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:75)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
In columns Attempting to expand In columns causes an error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.selectable(widgetsSelectableLists.kt:126)
	at imgui.ImGui.selectable(imgui.kt:29)
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.selectable$default(widgetsSelectableLists.kt:125)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:512)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:231)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:79)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:75)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
Grid Attempting to expand Grid causes an error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 23
	at imgui.imgui.imgui_widgetsSelectableLists$DefaultImpls.selectable(widgetsSelectableLists.kt:126)
	at imgui.ImGui.selectable(imgui.kt:29)
	at imgui.imgui.demo.widgets.invoke(widgets.kt:521)
	at imgui.imgui.demo.ExampleApp.invoke(ExampleApp.kt:231)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:79)
	at imgui.ImGui.showTestWindow(imgui.kt:29)
	at imgui.imgui.imgui_demoDebugInfo$DefaultImpls.showTestWindow(demoDebugInfo.kt:75)
	at imgui.ImGui.showTestWindow(imgui.kt:29)

And more.. if these are caused by a dependency, let me know. If they're actual bugs on your side.. have fun fixing them :^) If so, I'll happily create another issue and (attempt to) list everything else I find. (sorry)

Basic bug is now fixed, I had to insert some cases for the last new StyleVar entries
And so are also all the selectables samples, it was a bit messy because all of them were based on one unique boolean array. Quite error prone indeed.. I split them up now (the logic selection of the "Grid" is still buggy, I'll fix it with calm)

you can pull last commit 👍 (8f1a3688d5)

Well, what may looks like unstable from an end user point of view, looks quite stable from others (like me :p )

Let me explain, it's quite easy to notice what is not working, while what is already working doesnt get so much visibility and doesn't get noticed easily.

Windows management, mouse interaction, and all (~) the components (that are many, I can assure) shall be quite stable (in b4 last famous words 😄 )

Anyway, I know you didn't mean to criticize in a bad way, but I just wanted to show you my point of view :)

Yeah, it's true, text input/handling is still the lib Achille's heel.. I'll try to get it working as soon as possible

doesn't look very japanese

I presume then you are japanese or you speak it.. excellent! If you want you may be my perfect mate to help me test it and deliver valuable feedbacks. That part hasnt been implemented at all yet..

Just so that you know, whenever you read An operation is not implemented., in the exception, it means you just hit a TODO()

Thanks for reporting!

Ps: I'll look forward for any new issue you find and report ;)

Lovely, thanks for the answer! I'll look out for more bugs, glitches etc and if I get more used to the workings of imgui, I'll definitely try to contribute more to the project. Considering my problem is resolved and a fix is in the comments, you can close this issue.

That sounds great!

Ps, grid selection bug is definitely over

Hi dear,

uncomment this line and you should get nice looking japanese characters :)

However, I need you support for the input part.. ^^

Sorry if I'm not completely up to the job, I'm not a japanese speaker, though I do know how to read & write some kanji/hiragana.
To write japanese, I use microsoft IME. What it does, is let you write romaji (what the japanese word sounds like, for example ひらがな is "hiragana")
and it converts that into japanese letters.
(There should be equivalents for linux and mac, but I'm not familiar with them)
Little preview:

2017-11-23_18-40-54
The main problem I see here would be making imgui and MS-IME fully compatible. However, you're in luck considering it looks like it's already semi-compatible.

When attempting to write in the one textfield I found not crashing instantly (which is the numerical one), The IME window appears at the very top-left of my screen. If I type something non-numerical, it'll appear in the IME box but not in the one imgui provides. Typing a number will also appear in the box, but will only appear inside imgui AFTER pressing enter (which is the 'confirm, this japanese word is correct'-key)

image

For numerical cases:
before pressing enter:
image
after pressing enter (the IME box dissapears, good sign)
image

Then, what is there left to do?

  1. The IME box should appear nicely aligned, under the textbox
  2. The IME box shouldn't display the text it is displaying, it should be displayed in the textbox itself first. However, the extra text it displays is "ghost text". It's not actually in the textbox yet. Pressing enter should be what triggers the IME handle to put the text in the box, and close the IME box.

This and this microsoft page talks about how the IME works. (incredibily outdated though, these were written for win xp)
Hope this helps!

edit: about the line that needed to be uncommented, isn't that kotlin code? I'm not using kotlin nor do I have a proper understanding of its syntax, so I'm kind of confused on that line of code :(

Spasi pointed that the wip is here: glfw/glfw#658

Also glfw/glfw#41 (targeting the 3.3 release),

Do you have any experience of IME and java? Can you point me something?

Btw: dont feel under pressure, take all the time you need, no stress at all

@elect86 Sadly, I don't have any experience related to IME. GLFW IME support being added is great news though! I guess we should just wait until that's out then.

No problems, we'll wait then.

Anyway, I just pushed, you have to write this:

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

I tried to replicate the ime implementation of libgdx and pushed

Give it a try when you have time :)

I pushed some code that should display relevant info in console whenever ime events get detected

Looks like that's working nicely. Box now strangely shows at the bottom right, and the textbox it provides is gone too. Feeling like progress! Also, I can type in the textboxes now, which is amazing. Good work!
Little question: beginGroup and endGroup should place the next components horizontally, right? I can't get that to work as intended.

imgui.beginGroup();
if (imgui.button("Load", new Vec2(100,20))) {
}
if (imgui.button("New", new Vec2(100,20))) {
}
imgui.endGroup();

will still show up as:
image

Box now strangely shows at the bottom right

Uhm.. do you get anything in console?

Good work!

Thanks! I'm glad you like it :)

Anyway, beginGroup is for:

/** Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)   */

You may be able to achieve what you want by adding sameLine() between the buttons. Not sure you need group though.

Uhm.. do you get anything in console?

Here's the log:

(I pressed key 'h' here)
Ime startComposition w: 0 l: 0
Ime composition/keyLast w: 65352 l: 441
Ime notify w: 269 l: 0
Ime notify w: 5 l: 1
Ime composition/keyLast w: 65352 l: 441
Ime composition/keyLast w: 65352 l: 441
(I pressed key 'i' here)
Ime composition/keyLast w: 12402 l: 441
Ime composition/keyLast w: 12402 l: 441
(I pressed enter here)
Ime notify w: 4 l: 1
Ime composition/keyLast w: 12402 l: 7680
Ime endComposition w: 0 l: 0
Ime notify w: 270 l: 0

That's all about IME though (and sometimes between IME related events: Ime setContex w: 0 l: 3221225487)

Do you remember also what did you type?

I need to know that in order to establish a relationship and figure it out what windows is detecting and how

This is one of the best Unicode tables I found so far, you may use that to point me with precision which character you pressed (or you meant to)

Sorry, I missed the lines in between.. can we take a japanese character as a test? What would you type and expect?

Yeah, the character ひ (hi). I inserted where and what I pressed in brackets in the log
(ex (I pressed key 'i' here)).

Look promising..

that 12402 at the end of the typing is the same code I see here under "HIRAGANA LETTER HI"

Can you confirm me it's right?

Also, can you confirm that those Ime notifications appear only during the box is open? And not when you type normal latin characters?

Edit: when you said you can type in textboxes, you meant does it work also with japanese characters?

That's the correct hiragana letter, yes.
About the notifications:

Ime setContex w: 0 l: 3221225487
Ime setContex w: 1 l: 3221225487

both of these show up from time to time (not sure what causes them), even when I'm not using IME.
When using IME, no text at all can be typed into the textboxes. The IME box suggestions update as expected, but pressing enter won't put the characters into the textbox. Also, what I'm typing doesn't appear in the box either.

Try pulling again

I'm setting a imeInProgress to true between an startComposition and endComposition

Also, when I get Ime composition/keyLast if imeInProgress == true, I set imeLastKey to the value received, otherwise I clear it to zero.

In the text rendering, the glyph will be displayed only if not in imeInProgress and imeLastKey != 0

This works if my assumption that first we get endComposition and then the key trigger is right..

Typing anything using IME now just makes all text vanish. Still can't manage to get anything into the box either. Sorry :(
image
Nothing special in particular is logged.

yep, it makes sense, I put it at too low level (for everything rendering text)

Now I moved at the inputTex, when user has to insert chars..

It should work, although with one char per time..

While the text doesn't vanish anymore, I still can't manage to type any japanese into the textbox. + I haven't pointed this out yet, but any japenese characters appear as a questionmark instead of the actual character. Maybe it's another one of those resources/jar bugs?

Whenever you see question marks it means your actual font doesnt have that glyph..

These two lines need to be uncommented (I commented them for the others)

Thing is, I've done that! You told me to do so previously, but it didn't work and I forgot to mention that.

It's really difficult to develop ime support on a machine where I can't test or debug...

Do you know if I can try on my machine (win10 x64) while keeping it in english?

Or may we also do a short teamviewer session where I try to debug directly on your machine?

You can type japanese on a english machine just fine.
To do so, you just have to add a japanese keyboard.
Try looking at this page. My bad for not telling you earlier, to be honest. I had assumed you used linux or something else.

Try pulling, you should be finally able to enter single japanese characters :)