|
|
@@ -3,6 +3,8 @@ extern crate piston_window;
|
|
|
use clap;
|
|
|
use clap::{App, Arg, SubCommand};
|
|
|
use piston_window::*;
|
|
|
+// use opengl_graphics::{ GlGraphics, OpenGL };
|
|
|
+// use graphics::{ Context, Graphics };
|
|
|
|
|
|
fn main() {
|
|
|
let matches = App::new("Oculante")
|
|
|
@@ -23,6 +25,8 @@ fn main() {
|
|
|
.build()
|
|
|
.unwrap();
|
|
|
|
|
|
+ // let ref mut gl = GlGraphics::new(opengl);
|
|
|
+
|
|
|
match Texture::from_path(
|
|
|
&mut window.create_texture_context(),
|
|
|
&img,
|
|
|
@@ -31,36 +35,68 @@ fn main() {
|
|
|
) {
|
|
|
Ok(texture) => {
|
|
|
window.set_lazy(true);
|
|
|
- while let Some(e) = window.next() {
|
|
|
- let mut offset = (0.0, 0.0);
|
|
|
|
|
|
+ let mut events = Events::new(EventSettings::new().lazy(true));
|
|
|
+ let mut offset = (100.0,0.0);
|
|
|
+ while let Some(e) = events.next(&mut window) {
|
|
|
+ if let Some(Button::Mouse(button)) = e.press_args() {
|
|
|
+ println!("Pressed mouse button '{:?}'", button);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ e.mouse_scroll(|d| {
|
|
|
+ });
|
|
|
e.mouse_cursor(|d| {
|
|
|
- offset.0 = d[0];
|
|
|
- offset.1 = d[1];
|
|
|
- // image(&texture, transform, gfx);
|
|
|
- // println!("Relative mouse moved '{} {}'", d[0], d[1])
|
|
|
+ println!("Relative mouse moved '{} {}'", d[0], d[1]);
|
|
|
+ // offset.0 = d[0];
|
|
|
+ // offset.1 = d[1];
|
|
|
+ // println!("Scrolled mouse '{}, {}'", d[0], d[1]);
|
|
|
+ println!("offset {:?}", offset);
|
|
|
+
|
|
|
+ });
|
|
|
+ e.resize(|args| {
|
|
|
+ println!("Resized '{}, {}'", args.window_size[0], args.window_size[1])
|
|
|
+ });
|
|
|
+
|
|
|
+ if let Some(args) = e.render_args() {
|
|
|
+ window.draw_2d(&e, |c, gfx, _| {
|
|
|
+ clear([0.3; 4], gfx);
|
|
|
+ // c.trans(111.0,1.0);
|
|
|
+ let transform = c.transform.trans(offset.0, offset.1);
|
|
|
|
|
|
- }
|
|
|
- );
|
|
|
+ image(&texture, transform, gfx);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // offset = (100.0, 0.0);
|
|
|
+ // while let Some(e) = window.next() {
|
|
|
+ // let mut offset = (0.0, 0.0);
|
|
|
|
|
|
- println!("Offset '{} {}'", offset.0, offset.1);
|
|
|
+ // e.mouse_cursor(|d| {
|
|
|
+ // offset.0 = d[0];
|
|
|
+ // offset.1 = d[1];
|
|
|
+ // // image(&texture, transform, gfx);
|
|
|
+ // // println!("Relative mouse moved '{} {}'", d[0], d[1])
|
|
|
|
|
|
- window.draw_2d(&e, |c, gfx, _| {
|
|
|
- clear([0.3; 4], gfx);
|
|
|
- // c.trans(111.0,1.0);
|
|
|
- let transform = c.transform.trans(offset.0, offset.1);
|
|
|
+ // window.draw_2d(&e, |c, gfx, _| {
|
|
|
+ // clear([0.3; 4], gfx);
|
|
|
+ // // c.trans(111.0,1.0);
|
|
|
+ // let transform = c.transform.trans(offset.0, offset.1);
|
|
|
|
|
|
- image(&texture, transform, gfx);
|
|
|
+ // image(&texture, transform, gfx);
|
|
|
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // );
|
|
|
|
|
|
- });
|
|
|
+ // // offset = (100.0, 0.0);
|
|
|
|
|
|
- if let Some(Button::Mouse(button)) = e.press_args() {
|
|
|
- println!("Pressed mouse button '{:?}'", button);
|
|
|
- }
|
|
|
- }
|
|
|
+ // println!("Offset '{} {}'", offset.0, offset.1);
|
|
|
+
|
|
|
+ // if let Some(Button::Mouse(button)) = e.press_args() {
|
|
|
+ // println!("Pressed mouse button '{:?}'", button);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
Err(e) => println!("Could not create texture. {}", e),
|
|
|
}
|