Imgui-app is an amalgamation of two amazing projects Dear Imgui and Sokol libraries into two files to make it very easy to start working with imgui. It might be useful when you need to do some UI quickly for a project but do not want to care that much how to get imgui up and running (imgui compilation, backend rendering, window handling, ...).
To start using imgui-app you need to add these two files to your project:
Once you are ready to display the UI, just call imgui_app
, see the example.
#include "imgui.h"
void frame() {
ImGui::Text("Hello, world %d", 123);
ImGui::ShowDemoWindow();
}
int main(int, char **) {
// when ready, call the UI:
imgui_app(frame, "IMGUI_APP", 800, 600);
// execution continues when window is closed
return 0;
}
Finally, make sure to select the proper sokol render backend, by compiling your project with -DSOKOL_GLCORE33
or any of the available backends.
This files are not required to use imgui-app, but if you need access to more advanced components from imgui or sokol here they are:
- imgui_internal.h. Might be needed if you need access to advanced rendering, or you us a 3rd party widget that requires it.
- sokol.h, amalgamation of sokol_app and sokol_time. You might require this if you want to initialize the window manually and provide callbacks for sokol events (input, drag and drop, etc...).
- Try not to modify the files
imgui.h
,imgui_app.cpp
, orimgui_internal.h
they are generated from the original sources by theMakefile
of this project - We chose to use imgui.h for the headers to make the project compatible with other exisiting imgui code.
- imgui_app.cpp is BIG, it is the result of including in one file imgui, sokol, and all the dependencies. Try not to compile every time on your project :)
- The amalgamation idea comes from Sqlite amalgamation