Added all new primitives

This commit is contained in:
STP
2023-11-27 21:37:00 -05:00
parent 5aa73bcc1a
commit 2757ce9730
7 changed files with 674 additions and 147 deletions

View File

@@ -224,11 +224,13 @@ pub fn run() -> Result<(), Box<dyn Error>> {
}
match event {
Event::WindowEvent { event, .. } => {
if let Err(_e) = handle_window_event(event, control_flow, &mut state) {
*control_flow = ControlFlow::Exit;
}
}
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
WindowEvent::Resized(size) => state.resize(&size).expect("Window Resize Error"),
WindowEvent::KeyboardInput { input, .. } => state.keyboard_input(&input),
WindowEvent::MouseInput { button, .. } => state.mouse_input(&button),
_ => {}
},
Event::RedrawRequested(_) => {
if let Err(_e) = state.render() {
@@ -255,18 +257,3 @@ fn create_pixels(window: &Window) -> Pixels {
let surface_texture = SurfaceTexture::new(window_size.width, window_size.height, window);
Pixels::new(1, 1, surface_texture).unwrap()
}
fn handle_window_event(
event: WindowEvent,
control_flow: &mut ControlFlow,
state: &mut State,
) -> Result<(), Box<dyn Error>> {
match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
WindowEvent::Resized(size) => state.resize(&size)?,
WindowEvent::KeyboardInput { input, .. } => state.keyboard_input(&input),
WindowEvent::MouseInput { button, .. } => state.mouse_input(&button),
_ => {}
};
Ok(())
}