LWJGL Forum

Programming => Vulkan => Topic started by: ealrann on July 12, 2018, 14:52:06

Title: Kotlin ImGui, doesn't receive input.
Post by: ealrann on July 12, 2018, 14:52:06
Hello,

I'm trying to use the Kotlin jvm port of ImGui (https://github.com/kotlin-graphics/imgui), with LWJGL/Vulkan.

I ported the code a CPP demo : https://github.com/SaschaWillems/Vulkan/blob/master/examples/imgui/main.cpp. I rendered it above one of my project, looks good.

The main problem is: ImGui doesn't catch the inputs. Every frame I set the io.MouseDown and the io.MousePos, but nothing happen (while my game is catching the inputs correctly). I directly get them from glfwGetCursorPos().
I think I missed something like (but it doesn't appear in the cpp demo, whatever..)
each frame, I added a call to :
      ImGui.INSTANCE.render();
      then => updateBuffers(); (from the demo code, the one that call the imgui.getDrawData()).

But still, nothing move in my UI.

Any idea would be welcome  :)

I didn't paste much code. Since vulkan is very verbose, I don't even know what copy/paste. Don't hesitate to tell me if you want more info/code.
Title: Re: Kotlin ImGui, don't receive input.
Post by: elect on July 12, 2018, 21:09:30
Hi ealrann,


can you show some code? Is your project open?
Title: Re: Kotlin ImGui, doesn't receive input.
Post by: elect on July 13, 2018, 07:53:33
Anyway, this (https://github.com/SaschaWillems/Vulkan/blob/master/examples/imgui/main.cpp#L782-L784) is the point where the mouse position and the status of the mouse buttons get passed to imgui. Print them out to check if they are really getting updated
Title: Re: Kotlin ImGui, doesn't receive input.
Post by: ealrann on July 13, 2018, 09:30:00
Well, while packing my project in order to send it to you, I found my problem.
I added a call to newFrame() (method from the demo) in my main loop, and now it works.
So, I don't really understand how the demo can work without that, I guess I need time to learn ImGui.

Anyway, thank you for your help Elect, and thank you for your jvm binding.
Title: Re: Kotlin ImGui, doesn't receive input.
Post by: elect on July 13, 2018, 10:30:27
Well, while packing my project in order to send it to you, I found my problem.

Glad you got it

I added a call to newFrame() (method from the demo) in my main loop, and now it works.
So, I don't really understand how the demo can work without that, I guess I need time to learn ImGui.

Actually the demo is calling
Code: [Select]
newFrame() here (https://github.com/SaschaWillems/Vulkan/blob/master/examples/imgui/main.cpp#L340) (called in turn by buildCommandBuffers() (https://github.com/SaschaWillems/Vulkan/blob/master/examples/imgui/main.cpp#L537))


Anyway, thank you for your help Elect, and thank you for your jvm binding.

Thanks but I did nothing  :D.

Anyway, since you got imgui working with vk before me, I'm interested in your implementation.. did you mirrored + or - Sasha example structure? Does it work nice for your project?
Title: Re: Kotlin ImGui, doesn't receive input.
Post by: ealrann on July 13, 2018, 12:23:28
Ok, now I understand.
Yeah I saw that the newFrame() is called by the buildCommandBuffer(), but I didn't though the commandBuffer would be rebuilt every frame.

For the record : the demo do that to update the scisors and eventually resize the buffers. I think a better approach would be to rebuilt it only when something is moved/resized on the UI.
Title: Re: Kotlin ImGui, doesn't receive input.
Post by: elect on July 13, 2018, 12:35:23
Yeah I saw that the newFrame() is called by the buildCommandBuffer(), but I didn't though the commandBuffer would be rebuilt every frame.

I also had the same though, so I directly break it to check if it was really called every time

For the record : the demo do that to update the scisors and eventually resize the buffers. I think a better approach would be to rebuilt it only when something is moved/resized on the UI.

I totally agree