main.rs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. extern crate piston_window;
  2. use clap;
  3. use clap::{App, Arg, SubCommand};
  4. use piston_window::*;
  5. fn main() {
  6. let matches = App::new("Oculante")
  7. .arg(
  8. Arg::with_name("INPUT")
  9. .help("Display this image")
  10. .required(true)
  11. .index(1),
  12. )
  13. .get_matches();
  14. let img = matches.value_of("INPUT").unwrap();
  15. let opengl = OpenGL::V3_2;
  16. let mut window: PistonWindow = WindowSettings::new("Oculante", [300, 300])
  17. .exit_on_esc(true)
  18. .graphics_api(opengl)
  19. .build()
  20. .unwrap();
  21. match Texture::from_path(
  22. &mut window.create_texture_context(),
  23. &img,
  24. Flip::None,
  25. &TextureSettings::new(),
  26. ) {
  27. Ok(texture) => {
  28. window.set_lazy(true);
  29. while let Some(e) = window.next() {
  30. window.draw_2d(&e, |c, g, _| {
  31. clear([1.0; 4], g);
  32. image(&texture, c.transform, g);
  33. });
  34. }
  35. }
  36. Err(e) => println!("Could not create texture. {}", e),
  37. }
  38. }