Remove explicit event handling to fix resize issue
This commit is contained in:
parent
ed8abb74e6
commit
0bfe5f1a12
21
src/main.rs
21
src/main.rs
@ -5,11 +5,6 @@ use std::process;
|
|||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use piston::EventLoop;
|
|
||||||
use piston::EventSettings;
|
|
||||||
use piston::Events;
|
|
||||||
use piston::RenderEvent;
|
|
||||||
|
|
||||||
use piston_window as pw;
|
use piston_window as pw;
|
||||||
use piston_window::PistonWindow;
|
use piston_window::PistonWindow;
|
||||||
use piston_window::WindowSettings;
|
use piston_window::WindowSettings;
|
||||||
@ -70,24 +65,21 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||||||
[1600, 800],
|
[1600, 800],
|
||||||
)
|
)
|
||||||
.exit_on_esc(true)
|
.exit_on_esc(true)
|
||||||
|
.vsync(true)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let mut events = Events::new(EventSettings::new().ups(cli.frame_rate));
|
|
||||||
|
|
||||||
let x_size = cli.cols;
|
let x_size = cli.cols;
|
||||||
let y_size = cli.rows;
|
let y_size = cli.rows;
|
||||||
while let Some(event) = events.next(&mut window) {
|
while let Some(event) = window.next() {
|
||||||
if let Some(args) = event.render_args() {
|
|
||||||
window.draw_2d(&event, |context, graphics, _device| {
|
window.draw_2d(&event, |context, graphics, _device| {
|
||||||
// let [vsx, vsy] = context.get_view_size();
|
let [vsx, vsy] = context.get_view_size();
|
||||||
let [vsx, vsy] = args.viewport().window_size;
|
|
||||||
|
|
||||||
// Compute cell size
|
// Compute cell size
|
||||||
let csx = vsx / (x_size as f64);
|
let csx = (vsx as f64) / (x_size as f64);
|
||||||
let csy = vsy / (y_size as f64);
|
let csy = (vsy as f64) / (y_size as f64);
|
||||||
let cs = csx.min(csy);
|
let cs = csx.min(csy);
|
||||||
|
|
||||||
pw::clear([0.0, 0.0, 0.0, 1.0], graphics);
|
pw::clear([0.5, 0.5, 0.5, 1.0], graphics);
|
||||||
|
|
||||||
stdout.read_exact(&mut buffer).expect("pipe read failed");
|
stdout.read_exact(&mut buffer).expect("pipe read failed");
|
||||||
if cli.debug >= 3 {
|
if cli.debug >= 3 {
|
||||||
@ -106,7 +98,6 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
frame_count += 1;
|
frame_count += 1;
|
||||||
}
|
}
|
||||||
child.kill()?;
|
child.kill()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user