britzl / extension-imgui

Dear ImGUI extension for Defold
MIT License
58 stars 19 forks source link

Dear ImGUI extension for Defold

This project adds support for Dear ImGUI in Defold. Dear ImGUI is described as a "Bloat-free Graphical User interface for C++ with minimal dependencies". It is perfect for quickly creating a debug interface or for creation of in-game tools and settings.

imgui1 imgui2

Why no auto-generated bindings?

Projects such as cimgui offers Dear ImGUI bindings for a number of different languages, including Lua. It could be used to generate the bindings for this extension, BUT I'm doing this as a way to learn more about the Dear ImGUI API and as such it makes more sense for me to write the bindings by hand.

IMPORTANT

Platforms support

The current state of platform support:

Usage

Refer to example/example.script to learn how to use the extension. Also check the bindings in LuaInit() in extension_imgui.cpp.

Input

You need to update the input state in Dear ImGUI each frame to accurately reflect user input:

You can add the imgui/imgui.script to a game object and let that handle input for you (also make sure to use imgui/bindings/imgui.input_bindings).

Display size

You need to let Dear ImGUI know of any changes to the window size by calling imgui.set_display_size(w, h) when the screen size changes.