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 .
.
There are several dependencies you might need to install on your linux machine. Take a look here
- 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.
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.
- For functions, 'Im/ImGui/ig' is trimmed.
Get
prefix is also removed.- If function comes from
imgui_internal.h
,Internal
prefix is added.
Unfortunately, in C there is no way to ditinguish between a pointer and a slice.
We had to bring this unpleasantness to Go as well.
Our code defaults to pointers, but you can easily convert your slice to a pointer by simply &(slice[0])
.
You can also use imgui.SliceToPtr
.
Please note that at the moment (November 2024) go (1.23) does not support passing annonymous functions to C via CGO. We have it workarounded by pre-generating large amount of global functions and a pool. For details see #224 . Just be aware of the limitation that you may run out of pre-generated pool and experience a crash.
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.
Install GNU make and run make
to re-generate bunding.
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.
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.