High-level Rust bindings to dear imgui

30 releases

new 0.5.0 Sep 19, 2020
0.4.0 May 27, 2020
0.3.0 Feb 15, 2020
0.2.1 Sep 9, 2019
0.0.5 Nov 30, 2015

#3 in GUI

Download history 811/week @ 2020-06-04 785/week @ 2020-06-11 968/week @ 2020-06-18 1554/week @ 2020-06-25 1176/week @ 2020-07-02 857/week @ 2020-07-09 740/week @ 2020-07-16 685/week @ 2020-07-23 710/week @ 2020-07-30 787/week @ 2020-08-06 1003/week @ 2020-08-13 1429/week @ 2020-08-20 1577/week @ 2020-08-27 1736/week @ 2020-09-03 1641/week @ 2020-09-10 1706/week @ 2020-09-17

5,134 downloads per month
Used in 43 crates (41 directly)


79K SLoC

C++ 32K SLoC // 0.1% comments Rust 24K SLoC // 0.0% comments Lua 17K SLoC Visual Studio Project 2.5K SLoC C 1.5K SLoC // 0.1% comments Objective-C++ 1.5K SLoC // 0.1% comments FORTRAN Legacy 167 SLoC Visual Studio Solution 67 SLoC Batch 54 SLoC GLSL 31 SLoC Objective-C 22 SLoC Shell 9 SLoC

imgui-rs: Rust bindings for Dear ImGui

Still fairly experimental!

Minimum Rust version: 1.40

Wrapped Dear ImGui version: 1.78

Build Status Latest release on crates.io Documentation on docs.rs

Hello world

Window::new(im_str!("Hello world"))
    .size([300.0, 100.0], Condition::FirstUseEver)
    .build(&ui, || {
        ui.text(im_str!("Hello world!"));
        let mouse_pos = ui.io().mouse_pos;
            "Mouse Position: ({:.1},{:.1})",
            mouse_pos[0], mouse_pos[1]

Main library crates

  • imgui: High-level safe API
  • imgui-glium-renderer: Renderer implementation that uses the glium crate
  • imgui-gfx-renderer: Renderer implementation that uses the gfx crate (not the new gfx-hal crate)
  • imgui-winit-support: Backend platform implementation that uses the winit crate (0.22 by default, but 0.19-0.21 are supported via feature flags)
  • imgui-sys: Low-level unsafe API (automatically generated)


  • Bindings for Dear ImGui that can be used with safe Rust. Note: API coverage is not 100%, but will keep improving over time.
  • Builder structs for use cases where the original C++ library uses optional function parameters
  • &ImStr / ImString types and im_str! macro for defining and passing null-terminated UTF-8 to Dear ImGui, which doesn't accept Rust &str / String values. See issue #7 for more information and justification for this design.
  • Easy integration with Glium / pre-ll gfx (renderer)
  • Easy integration with winit (backend platform)

Choosing a backend platform and a renderer

Almost every application that uses imgui-rs needs two additional components in addition to the main imgui crate: a backend platform, and a renderer.

The backend platform is responsible for integrating imgui-rs with the operating system and its window management. Its responsibilities include the following:

  • Handling input events (e.g. keyboard, mouse) and updating imgui-rs state accordingly
  • Passing information about the OS window (e.g. size, DPI factor) to imgui-rs
  • Updating the OS-side mouse cursor when imgui-rs requests it

The renderer is responsible for taking generic, renderer-agnostic draw lists generated by imgui-rs, and rendering them using some graphics API. Its responsibilities include the following:

  • Rendering using vertex/index buffers and command lists
  • Handling of DPI factors and scissor rects
  • Texture management

The most tested platform/renderer combination is imgui-glium-renderer + glium + imgui-winit-support + winit, but this is not the only possible combination. There's also imgui-gfx-renderer, and you can find additional 3rd party crates that provide a wider support for more libraries (e.g. raw OpenGL, SDL2). You can also write your own support code if you have a more advanced use case, because imgui-rs is not tied to any specific graphics / OS API.

Compiling and running the demos

git clone https://github.com/Gekkio/imgui-rs
cd imgui-rs
git submodule update --init --recursive

Main examples are located in the imgui-examples directory.

# At the reposity root
cd imgui-examples
cargo test

cargo run --example hello_world
cargo run --example test_window
cargo run --example test_window_impl

Examples for the gfx backend are under the imgui-gfx-examples directory.

cd imgui-gfx-examples
cargo test

cargo run --example hello_world
cargo run --example test_window

Note to Windows users: You will need to use the MSVC ABI version of the Rust compiler along with its associated dependencies to build this libary and run the examples.

How to contribute

  1. Change or add something

  2. Make sure you're using the latest stable Rust

  3. Run rustfmt to guarantee code style conformance

    rustup component add rustfmt
    cargo fmt
  4. Open a pull request in Github


Licensed under either of

at your option.

Uses Dear ImGui and cimgui.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.