Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (32 sloc) 1.08 KB
extern crate piston_window;
extern crate find_folder;
use piston_window::*;
fn main() {
let mut window: PistonWindow = WindowSettings::new(
"piston: hello_world",
[200, 200]
)
.exit_on_esc(true)
//.opengl(OpenGL::V2_1) // Set a different OpenGl version
.build()
.unwrap();
let assets = find_folder::Search::ParentsThenKids(3, 3)
.for_folder("assets").unwrap();
println!("{:?}", assets);
let mut glyphs = window.load_font(assets.join("FiraSans-Regular.ttf")).unwrap();
window.set_lazy(true);
while let Some(e) = window.next() {
window.draw_2d(&e, |c, g, device| {
let transform = c.transform.trans(10.0, 100.0);
clear([0.0, 0.0, 0.0, 1.0], g);
text::Text::new_color([0.0, 1.0, 0.0, 1.0], 32).draw(
"Hello world!",
&mut glyphs,
&c.draw_state,
transform, g
).unwrap();
// Update glyphs before rendering.
glyphs.factory.encoder.flush(device);
});
}
}
You can’t perform that action at this time.