Hello Guest

Kotlin ImGui, doesn't receive input.

  • 6 Replies
  • 1030 Views
Kotlin ImGui, doesn't receive input.
« 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.
« Last Edit: July 13, 2018, 01:00:11 by ealrann »

*

Offline elect

  • *
  • 18
Re: Kotlin ImGui, don't receive input.
« Reply #1 on: July 12, 2018, 21:09:30 »
Hi ealrann,


can you show some code? Is your project open?

*

Offline elect

  • *
  • 18
Re: Kotlin ImGui, doesn't receive input.
« Reply #2 on: July 13, 2018, 07:53:33 »
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
« Last Edit: July 13, 2018, 08:24:01 by elect »

Re: Kotlin ImGui, doesn't receive input.
« Reply #3 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.

*

Offline elect

  • *
  • 18
Re: Kotlin ImGui, doesn't receive input.
« Reply #4 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 (called in turn by buildCommandBuffers())


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?
« Last Edit: July 13, 2018, 12:47:55 by spasi »

Re: Kotlin ImGui, doesn't receive input.
« Reply #5 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.

*

Offline elect

  • *
  • 18
Re: Kotlin ImGui, doesn't receive input.
« Reply #6 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