A very light ImGui wrapper
If you need a simple ImGui wrapper for your code that frees you from writing boilerplate code, imgui_interface is for you. It only provides three functions:
bool imgui_init(int width, int height, const char* title);
bool imgui_loop(std::function<void()> user_renderer, std::initializer_list<float> background_color = { 0.1f, 0.1f, 0.1f });
void imgui_cleanup();The current version uses GLFW and OpenGL 3, hence the corresponding headers and libraries must be installed. init.sh can be used to clone ImGui from GitHub. build.sh can be used to compile your project using g++.
To add ImGui to your code, just do the following:
#include "imgui_interface.hpp"- In the initialization part of your code, call
imgui_init(width, height, title) - Write your renderer logic inside a lambda (or equivalents) and pass it to
imgui_loop(user_renderer, { r, g, b })where{ r, g, b }is the color code of the window background. - To clean things up, call
imgui_cleanup().
The current configuration uses GLFW/OpenGL 3 backend. To use other backends, install the requirements and change imgui_interface.hpp and imgui_interface.cpp based on ImGui's documentation.
To build and run the examples, run init.sh once to clone ImGui and then use the following commands to build the examples:
$ ./build.sh example-1
$ ./build.sh example-2