Remove explicit event handling to fix resize issue

This commit is contained in:
Juergen Stuber 2023-04-11 09:55:56 +02:00
parent ed8abb74e6
commit 0bfe5f1a12

View File

@ -5,11 +5,6 @@ use std::process;
use clap::Parser;
use piston::EventLoop;
use piston::EventSettings;
use piston::Events;
use piston::RenderEvent;
use piston_window as pw;
use piston_window::PistonWindow;
use piston_window::WindowSettings;
@ -70,24 +65,21 @@ fn main() -> Result<(), Box<dyn error::Error>> {
[1600, 800],
)
.exit_on_esc(true)
.vsync(true)
.build()?;
let mut events = Events::new(EventSettings::new().ups(cli.frame_rate));
let x_size = cli.cols;
let y_size = cli.rows;
while let Some(event) = events.next(&mut window) {
if let Some(args) = event.render_args() {
while let Some(event) = window.next() {
window.draw_2d(&event, |context, graphics, _device| {
// let [vsx, vsy] = context.get_view_size();
let [vsx, vsy] = args.viewport().window_size;
let [vsx, vsy] = context.get_view_size();
// Compute cell size
let csx = vsx / (x_size as f64);
let csy = vsy / (y_size as f64);
let csx = (vsx as f64) / (x_size as f64);
let csy = (vsy as f64) / (y_size as f64);
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");
if cli.debug >= 3 {
@ -106,7 +98,6 @@ fn main() -> Result<(), Box<dyn error::Error>> {
}
}
});
}
frame_count += 1;
}
child.kill()?;