Page 1 of 1

ImGui FFI bindings! (Super early alpha)

Posted: Thu Mar 22, 2018 12:55 am
by nikki93
Hi all! :ultrahappy:

I've begun working on ImGui bindings for LÖVE that use LuaJIT's FFI system. Here's a screenshot of it working:
Screenshot 2018-03-21 17.40.31.png
Screenshot 2018-03-21 17.40.31.png (488.42 KiB) Viewed 3797 times
It also works on iOS (I had to change 'ios.mm' in the LÖVE source a bit to get arrow keys + modifier keys working, will post that separately at some point):
IMG_3761.JPG
IMG_3761.JPG (2.34 MiB) Viewed 3797 times
Due to EXIF shenanigans the above image is upside down on the forums... But you get the idea. ^^

I'll make a repository for the code this weekend, but here's a gist for now. The gist also has a diff showing how to integrate it with usual LÖVE application code.

Right now the main Lua stuff added over the direct C FFI is the I/O event forwarding and drawing. Both use LÖVE APIs, no direct OpenGL or C tricks. This way it's more extensible in Lua.

This is definitely super early and I'll start working on actual ergonomic wrappers over the bare FFI but thought I'd post this already to gauge interest. One thing that could be nice is all the wrapping will be written in Lua and thus more manageable / extensible than writing it in C and dealing with the Lua stack to pass arguments and return types. There are tradeoffs across both approaches, but hey, now you have a choice between the two!

(Thanks to love-imgui, BTW, for 'imgui_impl.cpp' which was really helpful in figuring out Love <-> ImGui event and draw binding)

Re: ImGui FFI bindings! (Super early alpha)

Posted: Thu Mar 22, 2018 6:02 am
by Nelvin
Looks very interesting.
I plan to add some editor features to my game soon and your imgui binding might be a decent choice.

Re: ImGui FFI bindings! (Super early alpha)

Posted: Thu Mar 22, 2018 8:43 am
by Fenrir
Wow really nice and glad my work helped you a bit! :)