Git Product home page Git Product logo

hlimgui's Introduction

Heaps/HashLink native binding for Dear ImGui

Build & Install

First, make sure that HashLink, CMake and a C/C++ compiler are installed on your system.

Then the native extension needs to be built with these commands:

cd extension
mkdir build
cd build

cmake ..
cmake --build .

It builds a the target hdll file, and copy it to the root of the project.

Another method is to build it inside Visual Studio Code with CMake Tools extension installed, so you don't have to deal with the command line.

To add this library to your project, you need to include these files:

  • The previously compiled hlimgui.hdll file.
  • imgui/ImGuiDrawable.hx: this class derives from the standard Heaps Drawable class and contains/displays all ImGui widgets.
  • imgui/ImGui.hx: interface to the native extension.

See Main.hx to see how to implement this library.

Supported ImGui features

Most of the ImGui functionalities are supported and binded. Look at https://github.com/ocornut/imgui to get documentation on exposed functions AND how ImGui works.

Here is a list of unsupported features and changes:

  • Custom fonts aren't implemented.
  • As Haxe doesn't support function overloading, so if two original functions have the same name, the second one in Haxe has a suffix 2 to disguish it. For example:
public static function treeNode(label : String) : Bool {return false;}
public static function treeNode2(str_id : String, label : String) : Bool {return false;}
  • ImGui has several functions which take a variable number of parameters in order to format strings. This feature isn't supported in Haxe, so all string formatting must be done in Haxe before passing it to ImGui.

  • InputText function takes a byte buffer as parameter. This needs to be converted to a string like this example:

var input_text_buffer = new hl.Bytes(128);
if (ImGui.inputText('Text', input_text_buffer, 128)) {
    var st = @:privateAccess String.fromUTF8(input_text_buffer);
    trace(st);
}
  • The function setIniFilename doesn't exist in ImGui, it has been added to modify the filename of the default ini file saved by ImGui (pass null to turn off this feature).

  • Due to type conversions between Haxe and ImGui, editing the object returned from getStyle does not immediately update the default styles. The setStyle method has been added to provide that functionality. For example:

var style:ImGuiStyle = ImGui.getStyle();
style.WindowBorderSize = 0;
style.WindowRounding = 0;
ImGui.setStyle(style);

Bugs

If you find bugs, please report them on the GitHub project page. Most of the binded functions have been tested, but as it's a new library some bugs might remain.

Thanks

I would like to thanks Aidan63 for their Haxe/cpp binding. I have borrowed all the structure declaration code which remains the same between the two bindings.

hlimgui's People

Contributors

austineast avatar haddock7 avatar nspitko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hlimgui's Issues

Cannot open include file "Hl.h"

Followed the instructions to build the hlimgui but gives the error "cannot open include file: 'hl.h' Is this maybe missing from the repository or should I grab this header file from somewhere else?

No way to register textures with imgui

ImGuiDrawableBuffers defines a path for linking heaps textures with imgui, however, the entire class is private.

A quick fix is to just remove the private qualifier, but it's less than ideal from an API standpoint. I'm also not entirely sure how Heaps would react if you called dispose() but were sharing in-use textures with imgui.

hl.h is missing

I tried compiling the project, but there is a missing hl.h header file causing the compile error.

Error when linking CXX shared library

When trying to build the library, i always encounter an error at the linking step. My output is the following :

C:\Projects\haddock7.hlimgui\extension\build> cmake --build .
[1/1] Linking CXX shared library hlimgui.hdll
FAILED: hlimgui.hdll hlimgui.lib 
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -fuse-ld=lld-link -nostartfiles -nostdlib -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt   
-shared -o hlimgui.hdll  -Xlinker /implib:hlimgui.lib -Xlinker /pdb:hlimgui.pdb -Xlinker /version:0.0 CMakeFiles/hlimgui.hdll.dir/clipping.cpp.obj CMakeFiles/hlimgui.hdll.dir/columns.cpp.obj CMakeFiles/hlimgui.hdll.dir/context.cpp.obj CMakeFiles/hlimgui.hdll.dir/cursor.cpp.obj CMakeFiles/hlimgui.hdll.dir/demo.cpp.obj CMakeFiles/hlimgui.hdll.dir/docking.cpp.obj CMakeFiles/hlimgui.hdll.dir/focus.cpp.obj CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj CMakeFiles/hlimgui.hdll.dir/id.cpp.obj CMakeFiles/hlimgui.hdll.dir/io.cpp.obj CMakeFiles/hlimgui.hdll.dir/logging.cpp.obj CMakeFiles/hlimgui.hdll.dir/parameters_stack.cpp.obj CMakeFiles/hlimgui.hdll.dir/popup.cpp.obj CMakeFiles/hlimgui.hdll.dir/style.cpp.obj CMakeFiles/hlimgui.hdll.dir/tab.cpp.obj CMakeFiles/hlimgui.hdll.dir/tooltip.cpp.obj CMakeFiles/hlimgui.hdll.dir/utilities_clipboard.cpp.obj CMakeFiles/hlimgui.hdll.dir/utilities_color.cpp.obj CMakeFiles/hlimgui.hdll.dir/utilities_ini.cpp.obj CMakeFiles/hlimgui.hdll.dir/utilities_keyboard.cpp.obj CMakeFiles/hlimgui.hdll.dir/utilities_misc.cpp.obj CMakeFiles/hlimgui.hdll.dir/utilities_mouse.cpp.obj CMakeFiles/hlimgui.hdll.dir/utilities_text.cpp.obj CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_combo.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_drag.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_input.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_listbox.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_main.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_menu.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_plot.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_selectable.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_slider.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_text.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_tree.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_utility.cpp.obj CMakeFiles/hlimgui.hdll.dir/widgets_value.cpp.obj CMakeFiles/hlimgui.hdll.dir/windows.cpp.obj CMakeFiles/hlimgui.hdll.dir/windows_color.cpp.obj CMakeFiles/hlimgui.hdll.dir/windows_region.cpp.obj CMakeFiles/hlimgui.hdll.dir/windows_scrolling.cpp.obj CMakeFiles/hlimgui.hdll.dir/windows_utilities.cpp.obj CMakeFiles/hlimgui.hdll.dir/imgui/imgui.cpp.obj CMakeFiles/hlimgui.hdll.dir/imgui/imgui_demo.cpp.obj CMakeFiles/hlimgui.hdll.dir/imgui/imgui_draw.cpp.obj CMakeFiles/hlimgui.hdll.dir/imgui/imgui_widgets.cpp.obj  C:/HaxeToolkit/hl/libhl.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cmd.exe /C "cd /D C:\Projects\haddock7.hlimgui\extension\build && "C:\Program Files\CMake\bin\cmake.exe" -E copy C:/Projects/haddock7.hlimgui/extension/build/hlimgui.hdll ../..""
lld-link: error: undefined symbol: hlt_dynobj
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj:(void __cdecl setStructImVec2(struct vdynamic *, char const *, struct ImVec2 const &))
>>> referenced 2 more times

lld-link: error: undefined symbol: hlt_bytes
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced 1 more times

lld-link: error: undefined symbol: hlt_array
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj:(void __cdecl getStructArrayImVec4(struct vdynamic *, char const *, struct ImVec4 *, int))     
>>> referenced 1 more times

lld-link: error: undefined symbol: hlt_i32
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(void __cdecl renderDrawLists(struct ImDrawData *))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/hlimgui.cpp.obj:(hlimgui_initialize)
>>> referenced 4 more times

lld-link: error: undefined symbol: hlt_bool
>>> referenced by CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj:(void __cdecl getStructBool(struct vdynamic *, char const *, bool &))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj:(void __cdecl setStructBool(struct vdynamic *, char const *, bool))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj:(struct ImGuiStyle __cdecl getImGuiStyleFromHL(struct vdynamic *))
>>> referenced 1 more times

lld-link: error: undefined symbol: hlt_dyn
>>> referenced by CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj:(void __cdecl getStructImVec2(struct vdynamic *, char const *, struct ImVec2 &))
>>> referenced by CMakeFiles/hlimgui.hdll.dir/utils.cpp.obj:(struct ImGuiStyle __cdecl getImGuiStyleFromHL(struct vdynamic *))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I use a combination of CMake, Ninja and Clang and don't understand where the issue could come from. What could i be doing wrong ?

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.