Kotlin ImGui, doesn't receive input.

Started by ealrann, July 12, 2018, 14:52:06

Previous topic - Next topic

ealrann

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.

elect

Hi ealrann,


can you show some code? Is your project open?

elect

Anyway, this 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

ealrann

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.

elect

Quote from: ealrann on July 13, 2018, 09:30:00
Well, while packing my project in order to send it to you, I found my problem.

Glad you got it

Quote from: ealrann on July 13, 2018, 09:30:00
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
newFrame()
here (called in turn by buildCommandBuffers())


Quote from: ealrann on July 13, 2018, 09:30:00
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?

ealrann

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.

elect

Quote from: ealrann on July 13, 2018, 12:23:28
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

Quote from: ealrann on July 13, 2018, 12:23:28
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