wasm: Enable backtraces in browser console
[mandelwow.git] / lib.rs
1 extern crate cgmath;
2 #[macro_use(uniform,implement_vertex)]
3 extern crate glium;
4 extern crate glutin;
5 #[cfg(feature = "image")]
6 extern crate image;
7 extern crate libxm;
8 #[cfg(feature = "editor")]
9 extern crate rust_rocket;
10 extern crate sdl2;
11
12 pub mod bounding_box;
13 pub mod cube;
14 pub mod mandelwow;
15 pub mod shaded_cube;
16 pub mod sound;
17 pub mod support;
18 pub mod text;
19 pub mod timer;
20
21 pub use bounding_box::BoundingBox;
22 pub use cube::Cube;
23 pub use shaded_cube::ShadedCube;
24
25 #[cfg(feature = "image")]
26 pub fn screenshot(display : &glium::Display) {
27     let image: glium::texture::RawImage2d<u8> = display.read_front_buffer();
28     let image = image::ImageBuffer::from_raw(image.width, image.height, image.data.into_owned()).unwrap();
29     let image = image::DynamicImage::ImageRgba8(image).flipv().to_rgb();
30     let image = image::DynamicImage::ImageRgb8(image);
31     let mut output = std::fs::File::create(&std::path::Path::new("screenshot.png")).unwrap();
32     image.write_to(&mut output, image::ImageFormat::PNG).unwrap();
33 }
34
35 #[cfg(not(feature = "image"))]
36 pub fn screenshot(_ : &glium::Display) {
37 }