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.77 and newer and is built if MAGNUM_WITH_IMGUI is enabled when building Magnum Integration. To use this library with CMake, put FindMagnumIntegration.cmake and FindImGui.cmake into your modules/ directory, 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.

Classes

class Context
Dear ImGui context.

Functions

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(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 new in 2019.10
ImageButton widget displaying a GL::Texture2D.

Function documentation

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(GL::Texture2D& texture, const Vector2& size, const Range2D& uvRange = {{}, Vector2{1.0f}}, Int framePadding = -1, const Color4& backgroundColor = {}, const Color4& tintColor = Color4{1.0f}) new in 2019.10

ImageButton 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)
framePadding Frame padding, negative values use the default frame padding
backgroundColor Background color, default 0x00000000_rgbaf
tintColor Tint color, default 0xffffffff_rgbaf