Fixed a minor issue
This commit is contained in:
parent
718c9688a8
commit
53d0760fc4
68
src/main.rs
68
src/main.rs
|
@ -49,7 +49,7 @@ fn main() -> Result<(), String> {
|
|||
|
||||
//println!("{:?} {:?} {:?}", texture.query(), texture.color_mod(), texture.alpha_mod());
|
||||
|
||||
let mut active_demo: Box<dyn Demo> = Box::new(demos::SimpleRectangle);
|
||||
let mut active_demo: &dyn Demo = &demos::SimpleRectangle;
|
||||
// TODO: Should update when window is unfocus since the project window retains
|
||||
// data from overlapped window
|
||||
// TODO: Maybe consider using condition variable to make loop {} not run at full
|
||||
|
@ -66,25 +66,61 @@ fn main() -> Result<(), String> {
|
|||
} => return Ok(()),
|
||||
Event::KeyUp { keycode, .. } => {
|
||||
match keycode {
|
||||
Some(Keycode::S) => active_demo.save_as_ppm(&buffer, width, height),
|
||||
Some(Keycode::Num1) => active_demo = Box::new(demos::SimpleRectangle),
|
||||
Some(Keycode::Num2) => {
|
||||
active_demo = Box::new(demos::LinearGradientRectangle)
|
||||
Some(Keycode::S) => {
|
||||
active_demo.save_as_ppm(&buffer, width, height);
|
||||
should_update = false;
|
||||
}
|
||||
Some(Keycode::Num1) => {
|
||||
active_demo = &demos::SimpleRectangle;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num2) => {
|
||||
active_demo = &demos::LinearGradientRectangle;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num3) => {
|
||||
active_demo = &demos::SimpleSphere;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num4) => {
|
||||
active_demo = &demos::SurfaceNormalSphere;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num5) => {
|
||||
active_demo = &demos::HitableSphere;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num6) => {
|
||||
active_demo = &demos::SimpleAntialiasing;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num7) => {
|
||||
active_demo = &demos::DiffuseMaterials;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num8) => {
|
||||
active_demo = &demos::Materials;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num9) => {
|
||||
active_demo = &demos::DielectricMaterial;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num0) => {
|
||||
active_demo = &demos::PositionableCamera;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Minus) => {
|
||||
active_demo = &demos::DefocusBlur;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Equals) => {
|
||||
active_demo = &demos::FinalScene;
|
||||
should_update = true;
|
||||
}
|
||||
Some(Keycode::Num3) => active_demo = Box::new(demos::SimpleSphere),
|
||||
Some(Keycode::Num4) => active_demo = Box::new(demos::SurfaceNormalSphere),
|
||||
Some(Keycode::Num5) => active_demo = Box::new(demos::HitableSphere),
|
||||
Some(Keycode::Num6) => active_demo = Box::new(demos::SimpleAntialiasing),
|
||||
Some(Keycode::Num7) => active_demo = Box::new(demos::DiffuseMaterials),
|
||||
Some(Keycode::Num8) => active_demo = Box::new(demos::Materials),
|
||||
Some(Keycode::Num9) => active_demo = Box::new(demos::DielectricMaterial),
|
||||
Some(Keycode::Num0) => active_demo = Box::new(demos::PositionableCamera),
|
||||
Some(Keycode::Minus) => active_demo = Box::new(demos::DefocusBlur),
|
||||
Some(Keycode::Equals) => active_demo = Box::new(demos::FinalScene),
|
||||
None => unreachable!(),
|
||||
_ => (),
|
||||
};
|
||||
should_update = true;
|
||||
}
|
||||
Event::Window {
|
||||
win_event: WindowEvent::Resized(w, h),
|
||||
|
|
Loading…
Reference in New Issue
Block a user