c923d0831fbd8e6dd14f374df4fc3dbb7dc906fd
[mandelwow.git] / lib.rs
1 pub mod bounding_box;
2 pub mod cube;
3 pub mod mandelwow;
4 pub mod shaded_cube;
5 pub mod sound;
6 pub mod support;
7 pub mod text;
8 pub mod timer;
9
10 pub use crate::bounding_box::BoundingBox;
11 pub use crate::cube::Cube;
12 pub use crate::shaded_cube::ShadedCube;
13
14 #[cfg(feature = "image")]
15 pub fn screenshot(display : &glium::Display) {
16     let image: glium::texture::RawImage2d<'_, u8> = display.read_front_buffer();
17     let image = image::ImageBuffer::from_raw(image.width, image.height, image.data.into_owned()).unwrap();
18     let image = image::DynamicImage::ImageRgba8(image).flipv().to_rgb();
19     let image = image::DynamicImage::ImageRgb8(image);
20     let mut output = std::fs::File::create(&std::path::Path::new("screenshot.png")).unwrap();
21     image.write_to(&mut output, image::ImageFormat::PNG).unwrap();
22 }
23
24 #[cfg(not(feature = "image"))]
25 pub fn screenshot(_ : &glium::Display) {
26 }