ImGui is a bloat-free graphical user interface library for C/C++. It is portable, renderer agnostic and carries minimal amount of dependencies (only 3 files are needed). It is based on an "immediate" graphical user interface paradigm which allows you to build simple user interfaces with ease.
ImGui is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is portable, renderer agnostic and carries minimal amount of dependencies (only 3 files are needed). It is based on an "immediate" graphical user interface paradigm which allows you to build simple user interfaces with ease.
ImGui is designed to allow programmers to create "content creation" or "debug" tools (as opposed to tools for the average end-user). It favors simplicity and thus lacks certain features normally found in more high-level libraries, such as string localisation.
ImGui is designed to enable fast iteration and allow programmers to create "content creation" or "debug" tools (as opposed to tools for the average end-user). It favors simplicity and thus lacks certain features normally found in more high-level libraries, such as string localisation.
Usage example:
ImGui is particularly suited to integration in 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
![screenshot of sample code alongside its output with ImGui](/web/code_sample_01.png?raw=true)
After ImGui is setup in your engine, you can use it like in this example:
ImGui output vertex buffer and simple command-list that you can render in application. Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui within your existing codebase.
![screenshot of sample code alongside its output with ImGui](/web/code_sample_01.png?raw=true)
ImGui outputs vertex buffers and simple command-lists that you can render in your application. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
Gallery
-------
@ -20,12 +21,22 @@ Gallery
![screenshot 3](/web/test_window_03.png?raw=true)
![screenshot 4](/web/test_window_04.png?raw=true)
References
----------
The Immediate Mode GUI paradigm may at first appear unusual to some users. This is mainly because "Retained Mode" GUIs have been so widespread and predominant. The following links can give you a better understanding about how Immediate Mode GUIs works.
- [A presentation by Rickard Gustafsson and Johannes Algelind](http://www.cse.chalmers.se/edu/year/2011/course/TDA361/Advanced%20Computer%20Graphics/IMGUI.pdf).
- [Jari Komppa's tutorial on building an ImGui library](http://iki.fi/sol/imgui/).
- [Casey Muratori's original video that popularized the concept](https://mollyrocket.com/861).
Credits
-------
Developed by [Omar Cornut](http://www.miracleworld.net). The library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
Embeds [proggy_clean font](http://www.proggyfonts.net/) by Tristan Grimmer (also MIT license).
Embeds [proggy_clean](http://www.proggyfonts.net/) font by Tristan Grimmer (also MIT license).
Inspiration, feedback, and testing: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Matt Willis. Thanks!
io.DisplaySize=ImVec2((float)(rect.right-rect.left),(float)(rect.bottom-rect.top));// Display size, in pixels. For clamping windows positions.
io.DeltaTime=1.0f/60.0f;// Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.KeyMap[ImGuiKey_Tab]=VK_TAB;// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",ms_per_frame_avg,1000.0f/ms_per_frame_avg);
// Show the ImGui test window
// Most of user example code is in ImGui::ShowTestWindow()
if(show_test_window)
{
// More example code in ShowTestWindow()
ImGui::SetNewWindowDefaultPos(ImVec2(650,20));// Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
io.DisplaySize=ImVec2((float)w,(float)h);// Display size, in pixels. For clamping windows positions.
io.DeltaTime=1.0f/60.0f;// Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.PixelCenterOffset=0.5f;// Align OpenGL texels
io.KeyMap[ImGuiKey_Tab]=GLFW_KEY_TAB;// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",ms_per_frame_avg,1000.0f/ms_per_frame_avg);
// Show the ImGui test window
// Most of user example code is in ImGui::ShowTestWindow()
if(show_test_window)
{
// More example code in ShowTestWindow()
ImGui::SetNewWindowDefaultPos(ImVec2(650,20));// Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
voidSetTooltip(constchar*fmt,...);// set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). (currently no contention handling, last call win)
voidSetNewWindowDefaultPos(ImVec2pos);// set position of window that do
boolIsHovered();// was the last item active area hovered by mouse?
ImVec2GetItemBoxMin();// get bounding box of last item
ImVec2GetItemBoxMax();// get bounding box of last item
boolIsClipped(ImVec2item_size);// to perform coarse clipping on user's side (as an optimisation)
boolIsKeyPressed(intkey_index,boolrepeat=true);// key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
// User is responsible for providing a renderer for this in ImGuiIO::RenderDrawListFn
structImDrawList
{
ImVector<ImDrawCmd>commands;
// This is what you have to render
ImVector<ImDrawCmd>commands;// commands
ImVector<ImDrawVert>vtx_buffer;// each command consume ImDrawCmd::vtx_count of those
ImVector<ImVec4>clip_rect_buffer;// each PushClipRect command consume 1 of those
ImVector<ImVec4>clip_rect_stack_;// [internal] clip rect stack while building the command-list (so text command can perform clipping early on)
ImDrawVert*vtx_write_;// [internal] point within vtx_buffer after each add command. allow us to use less [] and .resize on the vector (often slow on windows/debug)
// [Internal to ImGui]
ImVector<ImVec4>clip_rect_stack;// [internal] clip rect stack while building the command-list (so text command can perform clipping early on)
ImDrawVert*vtx_write;// [internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)