mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
Add simplified hello world example
This commit is contained in:
parent
7976fbee99
commit
9d9dab7c8c
@ -2,14 +2,30 @@
|
|||||||
|
|
||||||
**Ultra hyper turbo cyber mega extra über experimental!!!**
|
**Ultra hyper turbo cyber mega extra über experimental!!!**
|
||||||
|
|
||||||
## Compiling and running the demo
|

|
||||||
|
|
||||||
|
```rust
|
||||||
|
frame.window()
|
||||||
|
.name(im_str!("Hello world"))
|
||||||
|
.size((300.0, 100.0), ImGuiSetCond_FirstUseEver)
|
||||||
|
.build(|| {
|
||||||
|
frame.text(im_str!("Hello world!"));
|
||||||
|
frame.text(im_str!("This...is...imgui-rs!"));
|
||||||
|
frame.separator();
|
||||||
|
let mouse_pos = frame.imgui().mouse_pos();
|
||||||
|
frame.text(im_str!("Mouse Position: ({:.1},{:.1})", mouse_pos.0, mouse_pos.1));
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compiling and running the demos
|
||||||
|
|
||||||
git clone https://github.com/Gekkio/imgui-rs
|
git clone https://github.com/Gekkio/imgui-rs
|
||||||
cd imgui-rs
|
cd imgui-rs
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
cargo test
|
cargo test
|
||||||
|
|
||||||
target/debug/test_window
|
target/debug/examples/hello_world
|
||||||
|
target/debug/examples/test_window
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
37
examples/hello_world.rs
Normal file
37
examples/hello_world.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#[macro_use]
|
||||||
|
extern crate glium;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate imgui;
|
||||||
|
extern crate time;
|
||||||
|
|
||||||
|
use imgui::*;
|
||||||
|
|
||||||
|
use self::support::Support;
|
||||||
|
|
||||||
|
mod support;
|
||||||
|
|
||||||
|
const CLEAR_COLOR: (f32, f32, f32, f32) = (1.0, 1.0, 1.0, 1.0);
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut support = Support::init();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let active = support.render(CLEAR_COLOR, |frame| {
|
||||||
|
hello_world(frame)
|
||||||
|
});
|
||||||
|
if !active { break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn hello_world<'a>(frame: &Frame<'a>) -> bool {
|
||||||
|
frame.window()
|
||||||
|
.name(im_str!("Hello world"))
|
||||||
|
.size((300.0, 100.0), ImGuiSetCond_FirstUseEver)
|
||||||
|
.build(|| {
|
||||||
|
frame.text(im_str!("Hello world!"));
|
||||||
|
frame.text(im_str!("This...is...imgui-rs!"));
|
||||||
|
frame.separator();
|
||||||
|
let mouse_pos = frame.imgui().mouse_pos();
|
||||||
|
frame.text(im_str!("Mouse Position: ({:.1},{:.1})", mouse_pos.0, mouse_pos.1));
|
||||||
|
})
|
||||||
|
}
|
||||||
BIN
hello_world.png
Normal file
BIN
hello_world.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Loading…
x
Reference in New Issue
Block a user