cimgui-go
This project aims to generate go wrapper for Dear ImGui.
It comes with several default backends implemented.
It works on macOS(arm64/x86), windows(x64), Arch Linux (Gnome/KDE) and Fedora Workstation 36+, idealy other linux GUI should works as well. Check out examples
: cd in and go run .
.
Setup
There are several dependencies you might need to install on your linux machine.
Take a look here
Current solution is:
- Use cimgui's lua generator to generate function and struct definition as json.
- Generate proper go code from the definition (via manual crafted go program).
- Use the backend implementation from imgui.
- Use github workflow to compile cimgui, glfw and other C dependencies to static lib and place them in ./lib folder for further link.
Supported Backends
In order to make it easy in use, cimgui-go implemented a few imgui backends. All of them are placed in backend/
sub-packages.
To see more details about usage of a specific backend, take a look at the examples.
We support the following backends:
- GLFW. (GLFW 3.3 + OpenGL)
- SDL2. (SDL 2 + OpenGL)
- Ebitengine (
import "github.com/AllenDang/cimgui-go/backend/ebitenbackend"
).
Important: Remember that various solution use different C libraries that can conflict with each other.
It is recommended to not enable e.g. GLFW and SDL backends at the same time as it may result in linker crash.
Naming convention
- For functions, 'Im/ImGui/ig' is trimmed.
Get
prefix is also removed.
- If function comes from
imgui_internal.h
, Internal
prefix is added.
Function coverage
Currently most of the functions are generated, except memory related stuff (eg. memory allocator, storage management, etc...).
If you find any function is missing, report an issue.
Generate binding
Install GNU make and run make
to re-generate bunding.
Update
To update to the latest version of dependencies, run make update
.
After doing this, commit changes and navigate to GitHub.
In Actions tab, manually trigger Compile cimgui
workflows.
How does it work?
cwrappers/
directory holds C binding for C++ Dear ImGui libraries
- generator bases on
cwrappers/{package_name}_templates
and generates all necessary GO/C code placing it in {pkgname}/
directories in the root of cimgui-go
libs/
contains pre-built shared libraries. cflags.go
includes and uses to decrease building time.