# HG changeset patch # User Emmanuel Gil Peyrot # Date 1580318304 -3600 # Node ID 31897f650d2d3f8cd0fc85ea9463c0761a7222f0 # Parent ee45bfde91bb9be811cb9e5ba7e48294ebf4cb83 examples: Add a third screen to the menu diff --git a/examples/menu.rs b/examples/menu.rs --- a/examples/menu.rs +++ b/examples/menu.rs @@ -133,15 +133,23 @@ fn main() { .build() .unwrap(); + let tl_dat = directory.join("TL.DAT"); + let mut tl_pbg3 = pbg3::from_path_buffered(tl_dat).expect("TL.DAT present"); + let mut back_buffer = surface.back_buffer().unwrap(); let mut resize = false; let mut frame = 0; + let mut z_pressed = false; + let mut x_pressed = false; 'app: loop { for event in surface.poll_events() { match event { WindowEvent::Close | WindowEvent::Key(Key::Escape, _, Action::Release, _) => break 'app, + WindowEvent::Key(Key::Z, _, Action::Press, _) => z_pressed = true, + WindowEvent::Key(Key::X, _, Action::Press, _) => x_pressed = true, + WindowEvent::FramebufferSize(..) => { resize = true; } @@ -157,13 +165,17 @@ fn main() { frame += 1; if frame == 60 { - let tl_dat = directory.join("TL.DAT"); - let mut tl_pbg3 = pbg3::from_path_buffered(tl_dat).expect("IN.DAT present"); - let jpeg = tl_pbg3.get_file("title00.jpg", true).expect("th06logo.jpg in IN.DAT"); + let jpeg = tl_pbg3.get_file("title00.jpg", true).expect("title00.jpg in TL.DAT"); let image = common::load_from_data(&jpeg).expect("th06logo.jpg decodable"); common::reupload_texture_from_rgb_image(&mut background, image).expect("upload data to texture"); } + if frame >= 60 && z_pressed { + let jpeg = tl_pbg3.get_file("select00.jpg", true).expect("select00.jpg in TL.DAT"); + let image = common::load_from_data(&jpeg).expect("select00.jpg decodable"); + common::reupload_texture_from_rgb_image(&mut background, image).expect("upload data to texture"); + } + // here, we need to bind the pipeline variable; it will enable us to bind the texture to the GPU // and use it in the shader surface