From 9d9dab7c8ca67fc06b584003bb88a69d318b6fe0 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Thu, 20 Aug 2015 19:13:59 +0300 Subject: [PATCH] Add simplified hello world example --- README.markdown | 20 ++++++++++++++++++-- examples/hello_world.rs | 37 +++++++++++++++++++++++++++++++++++++ hello_world.png | Bin 0 -> 2942 bytes 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 examples/hello_world.rs create mode 100644 hello_world.png 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 0000000000000000000000000000000000000000..0561770989c361a5f0ff88d661eeae2674723711 GIT binary patch literal 2942 zcmd^Bc`)1i7XP7bTuW)W(Q+y3R&N!(Xw{NXOD(rT?bOnWrE04pG#blAYpb+Z35uXd zQAySIP}I(gP*TK_Xt;=_(KKSIMqc{ny_x&Rn|c4fnfICboO8a*nK|DxXTIm8*}*Kt zMPx+)01&sbG_wZ)fpWf078c~oD{-F*d?gfNV&y0-EIdoM{m5UQj5K$RbO`g0jJ|cx z4+sbi3-MErfZy};3yruP7P%?Z2?YSrV^(HY9AgSUQAdNM?w@+c8bVi>clOr${W1=9 z5>>Z!I?GuwXV|zDL$)-Z{7(BSF<7<_im{^O9uP6CqARue)%!dXcJK>2^2 z?U1g{W$Eoyj0Eyvn~b2lMx(D#*;sur32g3ZRo@7}WG-0ik@&8eH00ck2OT2oIgUNYp$AdlZ5hE@)aB6%4PUqOlP2GK2`-6ItNs~;8MnfibX2xPx zeH1J6TLqy>jxYG;3t4H!6!zhlht+lA?7j3`6f|ys5#2p%gndIDXP(xrjOnU`#et(k z;g>?gHN1F#jM^+uvK>kszU-y1DIF^H+wegD6t~}`V_+~&xsM^{%y+0a#z+Rp7HCV~ zY<6kOm}M?D#zcsqE$nxsI{ia&`ihyZeR#Xw zpeWAb+#F+VZNP+10ML?dcCxcL6|vNZxnXtL&8S;{e zuA~jIo|lf*)4`?oRYzQ#^h^Z=KTIxg3@G5$4>JOn1Me#*$muFnDF`aggmrRna3p8I z%_LXguK5O#YWy#jEVb38bjLeN2uNn>o&`!&kNuY_P0gbI{X5dJa;M42Pa>cr42{sb z`lXU6dAxTglifeq(1@4;?aDM$1QOKLZ4XHr!;eb`FDwVJa&ms0b&+enEJKK|irY^# z^*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