imgui-rs: Rust bindings for Dear ImGui

Still fairly experimental!

Minimum Rust version: 1.36

Wrapped Dear ImGui version: 1.72b

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

Hello world

rust ui.window(im_str!("Hello world")) .size([300.0, 100.0], Condition::FirstUseEver) .build(|| { ui.text(im_str!("Hello world!")); ui.text(im_str!("こんにちは世界!")); ui.text(im_str!("This...is...imgui-rs!")); ui.separator(); let mouse_pos = ui.io().mouse_pos; ui.text(im_str!("Mouse Position: ({:.1},{:.1})", mouse_pos[0], mouse_pos[1])); })

Main library crates

Features

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:

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:

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

bash 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.

```bash

At the reposity root

cd imgui-examples cargo test

cargo run --example helloworld cargo run --example testwindow cargo run --example testwindowimpl ```

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

```bash cd imgui-gfx-examples cargo test

cargo run --example helloworld cargo run --example testwindow ```

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

    bash rustup component add rustfmt cargo fmt

  4. Open a pull request in Github

License

Licensed under either of

at your option.

Uses Dear ImGui and cimgui.

Contribution

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.