Skip to content

Latest commit

 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oh My Dear ImGui (OMDI)

A bit more than minimal wrapper library for ImGui-based applications. For more details, see the documentation.

Usage

Cross-compiling OMDI

Pre-installing

First of all, download this repository with all of its submodules:

git clone --recurse-submodules -j $(nproc)
# or after downloading without submodules:
git submodule update --init --recursive -j $(nproc)

You can compile and install oh-my-dear-imgui using the install script:

./install.sh [-h]

In which case the library will be installed in $HOME/.omdi, or you can do that manually

cmake -B build
cmake --build build --config Release -j $(nproc)
cmake --install build --prefix=/install-path-for/omdi/

Then you can add the library as a dependency to your app:

find_package(oh-my-dear-imgui CONFIG REQUIRED)

set(EXEC main)
set(SRC main.cpp)
add_executable(${EXEC} ${SRC})

target_link_libraries(${EXEC} PRIVATE oh-my-dear-imgui::oh-my-dear-imgui)

And simply point to the install directory when compiling your application:

cmake -B build -D CMAKE_PREFIX_PATH=/install-path-for/omdi/

In-tree building

Alternatively, you can fetch OMDI as part of your build using FetchContent to build the library in-tree:

set(FETCHCONTENT_QUIET FALSE)
include(FetchContent)
FetchContent_Declare(
  oh-my-dear-imgui
  GIT_REPOSITORY https://github.com/haykh/oh-my-dear-imgui.git
  GIT_TAG master
  GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(oh-my-dear-imgui)

set(EXEC main)
set(SRC main.cpp)
add_executable(${EXEC} ${SRC})

target_link_libraries(${EXEC} PRIVATE oh-my-dear-imgui::oh-my-dear-imgui)

This typically takes a couple of minutes though, so is not recommended.

Using in applications

Below is a minimal example for using OMDI in your application:

#include <omdi.hpp> // import the main omdi header

auto main() -> int {
  auto state = omdi::State(); // define the application state
  auto app   = omdi::App(&state); // define the application object

  app.Init(&state); // initialize the application
  app.Render(&state); // enter the render loop

  return 0;
}

You can also use some or all of the built-in components by passing them to the app renderer which will process these automatically:

// managers
auto pickerDialogManager = omdi::PickerManager();
auto toastManager        = omdi::ToastManager();
auto fontManager         = omdi::FontManager();
auto screenshotManager   = omdi::ScreenshotManager();

// ui elements
auto styleDialog = omdi::StyleDialog();
auto menubar     = omdi::Menubar();

auto components = omdi::components_t {
  {      "menubar",     &menubar },
  { "style_dialog", &styleDialog }
};
auto managers = omdi::managers_t {
  {      "toast_manager",        &toastManager },
  {       "font_manager",         &fontManager },
  { "screenshot_manager",   &screenshotManager },
  {     "picker_manager", &pickerDialogManager }
};

app.Init(&state, managers);

app.Render(
  &state,
  [&]() {
    // custom rendering routine
  },
  components,
  managers);

Examples

A few standalone examples can be found in the examples/ directory. These can be compiled using simply:

cmake -B build -D omdi_BUILD_EXAMPLES=ON
cmake --build build -j

from the root of the repository.

Dependencies

Following depedencies are built in-tree:

  • Plog
  • toml11
  • stb
  • ImGui
  • ImPlot
  • ImGuiFileDialog

Following depedencies are assumed to be installed on the system:

  • glfw3
  • OpenGL

Features

  • basic manager classes for picker dialogs, toasts (notifications), screenshots, fonts, etc.;
  • basic ui component classes, e.g., menubars, etc.;
  • app state with optional conversion to/from toml;
  • functionality for error handling (safe rendering + error notification) at runtime;
  • external font/icon support (see src/assets/);
  • dependencies can be built from the downloaded submodules or fetched with CMake at compile time;
  • includes some third-party ImGui plugins (also built in-tree): ImPlot, ImGuiFileDialog;
  • includes GPU-accelerated version of ImPlot-s PlotHeatmap (courtesy of unmerged backends branch).

TODO

  • documentation
  • notifications (via ImGuiNotify)
  • GPU-accelerated heatmap
  • image export (via stb)
  • support for other backends

Useful links

About

Wrapper library for ImGui-based applications

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Contributors

Languages