Magnum::ImGuiIntegration namespace

Integration with Dear ImGui.

Conversion of math classes and rendering of Dear ImGui using Magnum.

Usage

This library depends on Dear ImGui 1.88 and newer and is built if MAGNUM_WITH_IMGUI is enabled when building Magnum Integration. To use this library with CMake, request the ImGui component of the MagnumIntegration package and link to the MagnumIntegration::ImGui target:

find_package(MagnumIntegration REQUIRED ImGui)

# ...
target_link_libraries(your-app PRIVATE MagnumIntegration::ImGui)

Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-integration and imgui repositories and do the following before calling find_package():

set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
set(MAGNUM_WITH_IMGUI ON CACHE BOOL "" FORCE)
add_subdirectory(magnum-integration EXCLUDE_FROM_ALL)

Configuration

Dear ImGui configuration can normally be manipulated at compile time by defining IMGUI_USER_CONFIG which is then included by the Dear ImGui library. However, this library already uses this feature and defining IMGUI_USER_CONFIG will not work correctly. In order to provide your own file you can instead define MAGNUM_IMGUIINTEGRATION_USER_CONFIG and this file will be included correctly:

target_compile_definitions(your-app PRIVATE
    MAGNUM_IMGUIINTEGRATION_USER_CONFIG="my_imconfig.h")

Routines for math type conversion are provided in Magnum/ImGuiIntegration/Integration.h, Magnum-based rendering backend for Dear ImGui is in the Context class. See also the ImGui example, Downloading and building integration libraries and Integration library usage with CMake.

ImGui version support policy

The oldest supported ImGui version is regularly bumped to one that was released roughly two years ago (so for example in September 2024 it's version 1.88, released in June 2022). This matches deprecation policy of the ImGui project itself, where APIs get removed in two years after they were marked as obsolete.

Classes

class Context
Dear ImGui context.

Functions

auto textureId(GL::Texture2D& texture) -> ImTextureID new in Git master
Create an ImTextureID for a GL::Texture2D.
void image(GL::Texture2D& texture, const Vector2& size, const Range2D& uvRange = {{}, Vector2{1.0f}}, const Color4& tintColor = Color4{1.0f}, const Color4& borderColor = {})
Image widget displaying a GL::Texture2D.
auto imageButton(const char* id, GL::Texture2D& texture, const Vector2& size, const Range2D& uvRange = {{}, Vector2{1.0f}}, const Color4& backgroundColor = {}, const Color4& tintColor = Color4{1.0f}) -> bool new in Git master
ImageButton widget displaying a GL::Texture2D.
auto imageButton(GL::Texture2D& texture, const Vector2& size, const Range2D& uvRange = {{}, Vector2{1.0f}}, Int framePadding = -1, const Color4& backgroundColor = {}, const Color4& tintColor = Color4{1.0f}) -> bool deprecated in Git master
ImageButton widget displaying a GL::Texture2D.

Function documentation

ImTextureID Magnum::ImGuiIntegration::textureId(GL::Texture2D& texture) new in Git master

Create an ImTextureID for a GL::Texture2D.

Internally, the ImTextureID is the underlying OpenGL texture ID, but that's an implementation detail that might change in the future.

void Magnum::ImGuiIntegration::image(GL::Texture2D& texture, const Vector2& size, const Range2D& uvRange = {{}, Vector2{1.0f}}, const Color4& tintColor = Color4{1.0f}, const Color4& borderColor = {})

Image widget displaying a GL::Texture2D.

Parameters
texture Texture to display
size Widget size
uvRange UV range on the texture (covers the whole texture by default)
tintColor Tint color, default 0xffffffff_rgbaf
borderColor Border color, default 0x00000000_rgbaf

bool Magnum::ImGuiIntegration::imageButton(const char* id, GL::Texture2D& texture, const Vector2& size, const Range2D& uvRange = {{}, Vector2{1.0f}}, const Color4& backgroundColor = {}, const Color4& tintColor = Color4{1.0f}) new in Git master

ImageButton widget displaying a GL::Texture2D.

Parameters
id Widget ID
texture Texture to display
size Widget size
uvRange UV range on the texture (covers the whole texture by default)
backgroundColor Background color, default 0x00000000_rgbaf
tintColor Tint color, default 0xffffffff_rgbaf

bool Magnum::ImGuiIntegration::imageButton(GL::Texture2D& texture, const Vector2& size, const Range2D& uvRange = {{}, Vector2{1.0f}}, Int framePadding = -1, const Color4& backgroundColor = {}, const Color4& tintColor = Color4{1.0f})

ImageButton widget displaying a GL::Texture2D.