All Projects → kdrag0n → Go Imgui

kdrag0n / Go Imgui

Licence: mit
Go bindings for the dear imgui immediate mode GUI library

go-imgui

Go bindings for the awesome dear imgui immediate mode GUI library, written in C++. These bindings are generated with SWIG.

Current imgui version: 1.51

Installation

Run this command to update or install the library:

go get -u github.com/armored-dragon/go-imgui

Usage

Usage is more or less identical to the C++ library. For example, imgui.ShowTestWindow() will show the built-in demo window, which contains usage of just about every feature imgui has to offer. All Im type prefixes are removed, so types like ImVec2 or ImFontAtlas become imgui.Vec2 and imgui.FontAtlas. ImGui type prefixes are also removed. Prefixes of flag constants are also removed, so ImGuiWindowFlags_NoResize will become imgui.WindowFlags_NoResize, and so on for other flags.

If you import the package under a different name, just use packagename. instead of imgui..

Nested Structs

Certain nested structs present in imgui, such as Glyph (ImFont::Glyph), are not available in these bindings. This is because SWIG doesn't support nested structs. Full list of such structs:

  • ImGuiTextFilter::TextRange
  • ImGuiStorage::Pair
  • ImFontAtlas::GlyphRangesBuilder
  • ImFontAtlas::CustomRect
  • ImFont::Glyph

Generating

To generate the bindings with SWIG, this command is used:

swig -go -cgo -c++ -intgosize 32 imgui.i

Full generate-and-build command (for convenience):

swig -go -cgo -c++ -intgosize 32 imgui.i && bash patch.sh && go install -x

Note: The result will not compile unless patch.sh is run. This is because SWIG fails to recognize a case of function overload ambiguity and the resulting call fails to compile.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].