Code Monkey home page Code Monkey logo

extension-imgui-defold's Introduction

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

  • The project currently only has bindings for a small subset of the Dear ImGUI API.
    • More bindings are added as I need them. Pull requests are accepted!
  • The project is not cross-platform - See below for list of supported platforms
    • The current version uses the imgui_impl_opengl3.cpp

Platforms support

The current state of platform support:

  • ✅ macOS
  • ✅ Linux
  • ✅ Windows
  • ✅ Android
  • ✅ iOS
  • ✅ HTML5

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:

  • imgui.set_key_down(key, pressed) - Set the pressed state of a key. The key must be one of the imgui.KEY_ constants
  • imgui.set_key_modifier_super(pressed)
  • imgui.set_key_modifier_alt(pressed)
  • imgui.set_key_modifier_ctrl(pressed)
  • imgui.set_key_modifier_shift(pressed)
  • imgui.add_input_character(text) - Add keyboard input
  • imgui.set_mouse_input(x, y, left, right, middle, wheel) - Set mouse state (position, buttons and wheel)

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.

extension-imgui-defold's People

Contributors

britzl avatar dlannan avatar aglitchman avatar vbif avatar dri-richard avatar justapotota avatar agulev avatar dlannan-fmad avatar dapetcu21 avatar u546342 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.