Mercurial > touhou
comparison examples/menu.rs @ 750:31897f650d2d
examples: Add a third screen to the menu
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 29 Jan 2020 18:18:24 +0100 |
parents | 8a022334a4c4 |
children | eab7dde1164f |
comparison
equal
deleted
inserted
replaced
749:ee45bfde91bb | 750:31897f650d2d |
---|---|
131 .add_vertices(DEFAULT_VERTICES) | 131 .add_vertices(DEFAULT_VERTICES) |
132 .set_mode(Mode::TriangleFan) | 132 .set_mode(Mode::TriangleFan) |
133 .build() | 133 .build() |
134 .unwrap(); | 134 .unwrap(); |
135 | 135 |
136 let tl_dat = directory.join("TL.DAT"); | |
137 let mut tl_pbg3 = pbg3::from_path_buffered(tl_dat).expect("TL.DAT present"); | |
138 | |
136 let mut back_buffer = surface.back_buffer().unwrap(); | 139 let mut back_buffer = surface.back_buffer().unwrap(); |
137 let mut resize = false; | 140 let mut resize = false; |
138 let mut frame = 0; | 141 let mut frame = 0; |
142 let mut z_pressed = false; | |
143 let mut x_pressed = false; | |
139 | 144 |
140 'app: loop { | 145 'app: loop { |
141 for event in surface.poll_events() { | 146 for event in surface.poll_events() { |
142 match event { | 147 match event { |
143 WindowEvent::Close | WindowEvent::Key(Key::Escape, _, Action::Release, _) => break 'app, | 148 WindowEvent::Close | WindowEvent::Key(Key::Escape, _, Action::Release, _) => break 'app, |
144 | 149 |
150 WindowEvent::Key(Key::Z, _, Action::Press, _) => z_pressed = true, | |
151 WindowEvent::Key(Key::X, _, Action::Press, _) => x_pressed = true, | |
152 | |
145 WindowEvent::FramebufferSize(..) => { | 153 WindowEvent::FramebufferSize(..) => { |
146 resize = true; | 154 resize = true; |
147 } | 155 } |
148 | 156 |
149 _ => (), | 157 _ => (), |
155 resize = false; | 163 resize = false; |
156 } | 164 } |
157 | 165 |
158 frame += 1; | 166 frame += 1; |
159 if frame == 60 { | 167 if frame == 60 { |
160 let tl_dat = directory.join("TL.DAT"); | 168 let jpeg = tl_pbg3.get_file("title00.jpg", true).expect("title00.jpg in TL.DAT"); |
161 let mut tl_pbg3 = pbg3::from_path_buffered(tl_dat).expect("IN.DAT present"); | |
162 let jpeg = tl_pbg3.get_file("title00.jpg", true).expect("th06logo.jpg in IN.DAT"); | |
163 let image = common::load_from_data(&jpeg).expect("th06logo.jpg decodable"); | 169 let image = common::load_from_data(&jpeg).expect("th06logo.jpg decodable"); |
170 common::reupload_texture_from_rgb_image(&mut background, image).expect("upload data to texture"); | |
171 } | |
172 | |
173 if frame >= 60 && z_pressed { | |
174 let jpeg = tl_pbg3.get_file("select00.jpg", true).expect("select00.jpg in TL.DAT"); | |
175 let image = common::load_from_data(&jpeg).expect("select00.jpg decodable"); | |
164 common::reupload_texture_from_rgb_image(&mut background, image).expect("upload data to texture"); | 176 common::reupload_texture_from_rgb_image(&mut background, image).expect("upload data to texture"); |
165 } | 177 } |
166 | 178 |
167 // here, we need to bind the pipeline variable; it will enable us to bind the texture to the GPU | 179 // here, we need to bind the pipeline variable; it will enable us to bind the texture to the GPU |
168 // and use it in the shader | 180 // and use it in the shader |