diff --git a/README.markdown b/README.markdown index 30d68f6..2c1ad46 100644 --- a/README.markdown +++ b/README.markdown @@ -2,14 +2,30 @@ **Ultra hyper turbo cyber mega extra über experimental!!!** -## Compiling and running the demo +![Hello world](hello_world.png) + +```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 cd imgui-rs git submodule update --init --recursive cargo test - target/debug/test_window + target/debug/examples/hello_world + target/debug/examples/test_window ## License diff --git a/examples/hello_world.rs b/examples/hello_world.rs new file mode 100644 index 0000000..1095da7 --- /dev/null +++ b/examples/hello_world.rs @@ -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)); + }) +} diff --git a/hello_world.png b/hello_world.png new file mode 100644 index 0000000..0561770 Binary files /dev/null and b/hello_world.png differ