Fixed capture
This commit is contained in:
parent
c6c26f7201
commit
1e638681a4
|
@ -58,6 +58,8 @@ fn main() {
|
||||||
// Set verbose flag
|
// Set verbose flag
|
||||||
verbose_log::set(matches.occurrences_of("verbose") > 0);
|
verbose_log::set(matches.occurrences_of("verbose") > 0);
|
||||||
|
|
||||||
|
let mut capture_count = 0;
|
||||||
|
|
||||||
use std::f64::{MIN, MAX};
|
use std::f64::{MIN, MAX};
|
||||||
let mut bbox = BoundingBox3::new(
|
let mut bbox = BoundingBox3::new(
|
||||||
Vector3::new(MAX, MAX, MAX),
|
Vector3::new(MAX, MAX, MAX),
|
||||||
|
@ -177,7 +179,25 @@ fn main() {
|
||||||
camera.target.x(), camera.target.y(), camera.target.z());
|
camera.target.x(), camera.target.y(), camera.target.z());
|
||||||
println!("\tUp: ({}, {}, {})",
|
println!("\tUp: ({}, {}, {})",
|
||||||
camera.up.x(), camera.up.y(), camera.up.z());
|
camera.up.x(), camera.up.y(), camera.up.z());
|
||||||
}
|
},
|
||||||
|
|
||||||
|
Event::WindowEvent {
|
||||||
|
event: WindowEvent::KeyboardInput {
|
||||||
|
input: glutin::KeyboardInput {
|
||||||
|
virtual_keycode: Some(VirtualKeyCode::C),
|
||||||
|
state: ElementState::Pressed, ..
|
||||||
|
}, ..
|
||||||
|
}, ..
|
||||||
|
|
||||||
|
} => {
|
||||||
|
|
||||||
|
// Make a screenshot
|
||||||
|
let size = renderer.gl_window().get_inner_size().unwrap();
|
||||||
|
let cap = renderer.capture(size);
|
||||||
|
cap.save(format!("capture-{}.png", capture_count)).unwrap();
|
||||||
|
capture_count += 1;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,8 @@ impl Renderer {
|
||||||
/// Returns a RgbaImageData of the corresponding frame.
|
/// Returns a RgbaImageData of the corresponding frame.
|
||||||
pub fn capture_rgba_image_data(&self, dimensions: LogicalSize) -> RgbaImageData {
|
pub fn capture_rgba_image_data(&self, dimensions: LogicalSize) -> RgbaImageData {
|
||||||
|
|
||||||
let dimensions: (u32, u32) = dimensions.into();
|
let dpi = self.gl_window().get_hidpi_factor();
|
||||||
|
let dimensions: (u32, u32) = dimensions.to_physical(dpi).into();
|
||||||
|
|
||||||
let rect = Rect {
|
let rect = Rect {
|
||||||
left: 0,
|
left: 0,
|
||||||
|
|
Loading…
Reference in New Issue