mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 21:48:36 +00:00
To avoid conflicts in dependency version, this commit put examples using different renderers in different crates. Especially, glium and gfx do not necessarily depend on the same version of glutin. We have two examples: - imgui-examples (main examples, use gfx renderer here) - imgui-glium-examples (basic hello_glium example + maybe some texture stuff) Once vulcano support lands, we may add: imgui-vulkano-examples. This commit currently only moves files around. We plan to use gfx as a "main2 renderer for now on as gfx is more actively maintained that glium. Subsequent commits will migrate some glium examples to gfx.
imgui-rs: Rust bindings for ImGui
Still fairly experimental!
Minimum Rust version: 1.26
Wrapped Dear ImGui version: 1.65
ui.window(im_str!("Hello world"))
.size((300.0, 100.0), ImGuiCond::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.imgui().mouse_pos();
ui.text(im_str!("Mouse Position: ({:.1},{:.1})", mouse_pos.0, mouse_pos.1));
})
Currently implemented things
- Low-level API (imgui-sys)
- Renderer for easy integration with Glium projects (optional)
- Parts of high-level API
- Not horrible way of defining and passing null-terminated UTF-8 to ImGui.
The macro
im_str!needs to be used most of the time. For more information and justification for this design, please see issue #7 - Parts of imgui_demo.cpp reimplemented in Rust as an API usage example (examples/test_window_impl.rs)
Important but unimplemented things
- Documentation (rustdoc)
- Support passing a custom Program to Glium renderer (e.g. from a shader cache, or custom shader)
Core design questions and current choices
- Closures VS begin/end pairs (current choice: closures)
- Mutable references VS return values (current choice: mutable references)
- Passing around Ui<'ui> VS passing around &'ui Ui (current choice: Ui<'ui>)
- Splitting the API to smaller pieces VS all draw calls in Ui (current choice: all draw calls in Ui)
- Builder pattern for optional arguments VS something else (current choice: builder)
- Mutation functions in builders VS self-consuming functions in builders (current choice: self-consuming)
Compiling and running the demos
Examples are under the imgui-examples directory.
git clone https://github.com/Gekkio/imgui-rs
cd imgui-rs
git submodule update --init --recursive
cd imgui-examples
cargo test
cargo run --example hello_world
cargo run --example test_window
cargo run --example test_window_impl
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
-
Change or add something
-
Run rustfmt to guarantee code style conformance
rustup component add rustfmt-preview cargo fmt -
Open a pull request in Github
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.
Description
Languages
Rust
99.9%
