Skip to content

Instantly share code, notes, and snippets.

@andrewcsmith
Created January 18, 2016 21:14
Show Gist options
  • Save andrewcsmith/55124112d67f84e18258 to your computer and use it in GitHub Desktop.
Save andrewcsmith/55124112d67f84e18258 to your computer and use it in GitHub Desktop.
See lines 19-22
extern crate piston;
extern crate piston_window;
extern crate graphics;
extern crate gfx_graphics;
use piston::input::*;
use piston::window::{Window as Win, AdvancedWindow, WindowSettings};
use piston_window::{PistonWindow as Window};
fn main() {
let mut window: Window = WindowSettings::new("Hello Piston!", [640, 480])
.exit_on_esc(true).fullscreen(true).build().unwrap();
for w in window {
while let Some(e) = w.events.borrow_mut().next() {
match e {
Event::Render(RenderArgs { ext_dt, width, height, .. } ) => {
w.draw_2d(|c, g| {
// This one works...
let rectangle = piston_window::Rectangle::new([0.5; 4]);
// but this one breaks! It's just a reexported module.
// let rectangle = graphics::Rectangle::new([0.5; 4]);
piston_window::clear(graphics::color::WHITE, g);
rectangle.draw([width as f64 / 2 as f64, height as f64 / 2 as f64, 10., 10.], &c.draw_state, c.transform, g);
});
},
_ => { }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment