capture takes (u32, u32)

This commit is contained in:
Thomas Forgione 2018-10-12 13:59:56 +02:00
parent e8eb9ac44b
commit da4e6cbf6b
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
2 changed files with 3 additions and 7 deletions

View File

@ -193,7 +193,7 @@ fn main() {
// Make a screenshot // Make a screenshot
let size = renderer.gl_window().get_inner_size().unwrap(); let size = renderer.gl_window().get_inner_size().unwrap();
let cap = renderer.capture(size); let cap = renderer.capture(size.into());
cap.save(format!("capture-{}.png", capture_count)).unwrap(); cap.save(format!("capture-{}.png", capture_count)).unwrap();
capture_count += 1; capture_count += 1;

View File

@ -14,7 +14,6 @@ use glium::uniforms::MagnifySamplerFilter;
use glium::draw_parameters::{DepthTest, Blend}; use glium::draw_parameters::{DepthTest, Blend};
use glium::index::{NoIndices, PrimitiveType}; use glium::index::{NoIndices, PrimitiveType};
use glium::glutin::GlWindow; use glium::glutin::GlWindow;
use glium::glutin::dpi::LogicalSize;
use scene::Scene; use scene::Scene;
use camera::{RenderCamera, mat_to_f32}; use camera::{RenderCamera, mat_to_f32};
@ -216,15 +215,12 @@ impl Renderer {
} }
/// Returns a DynamicImage of the corresponding frame. /// Returns a DynamicImage of the corresponding frame.
pub fn capture(&self, dimensions: LogicalSize) -> image::DynamicImage { pub fn capture(&self, dimensions: (u32, u32)) -> image::DynamicImage {
rgba_image_data_to_image(self.capture_rgba_image_data(dimensions)) rgba_image_data_to_image(self.capture_rgba_image_data(dimensions))
} }
/// 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: (u32, u32)) -> RgbaImageData {
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,