extern crate glium;
extern crate glutin;
+extern crate image;
extern crate libxm;
extern crate sdl2;
mod sound;
mod support;
+fn screenshot(display : &glium::Display) {
+ let image: glium::texture::RawImage2d<u8> = display.read_front_buffer();
+ let image = image::ImageBuffer::from_raw(image.width, image.height, image.data.into_owned()).unwrap();
+ let image = image::DynamicImage::ImageRgba8(image).flipv();
+ let mut output = std::fs::File::create(&std::path::Path::new("screenshot.png")).unwrap();
+ image.save(&mut output, image::ImageFormat::PNG).unwrap();
+}
+
fn main() {
let _soundplayer = sound::start();
KeyboardInput(Pressed, _, Some(VirtualKeyCode::B)) => {
bounding_box_enabled ^= true;
},
- KeyboardInput(Pressed, _, Some(VirtualKeyCode::F)) => {
- fullscreen ^= true;
- if fullscreen {
- glutin::WindowBuilder::new()
- .with_fullscreen(glutin::get_primary_monitor())
- .rebuild_glium(&display).unwrap();
- } else {
- glutin::WindowBuilder::new()
- .rebuild_glium(&display).unwrap();
- }
- },
KeyboardInput(Pressed, _, Some(VirtualKeyCode::P)) => {
pause ^= true;
},
KeyboardInput(Pressed, _, Some(VirtualKeyCode::PageDown)) => {
t -= 0.01;
},
+ KeyboardInput(Pressed, _, Some(VirtualKeyCode::F10)) => {
+ screenshot(&display);
+ },
+ KeyboardInput(Pressed, _, Some(VirtualKeyCode::F11)) => {
+ fullscreen ^= true;
+ if fullscreen {
+ // Not implemented on Linux
+ glutin::WindowBuilder::new()
+ .with_fullscreen(glutin::get_primary_monitor())
+ .with_depth_buffer(24)
+ .rebuild_glium(&display).unwrap();
+ } else {
+ //glutin::WindowBuilder::new()
+ // .rebuild_glium(&display).unwrap();
+ }
+ },
ev => camera.process_input(&ev),
}
}