Renderer gets size as LogicalSize

This commit is contained in:
Thomas Forgione 2018-09-19 10:53:58 +02:00
parent c5548b1d28
commit 02182af019
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 9 additions and 7 deletions

View File

@ -14,6 +14,7 @@ use glium::uniforms::MagnifySamplerFilter;
use glium::draw_parameters::{DepthTest, Blend};
use glium::index::{NoIndices, PrimitiveType};
use glium::glutin::GlWindow;
use glium::glutin::dpi::LogicalSize;
use scene::Scene;
use camera::{RenderCamera, mat_to_f32};
@ -215,29 +216,30 @@ impl Renderer {
}
/// Returns a DynamicImage of the corresponding frame.
pub fn capture(&self, dimensions: (u32, u32)) -> image::DynamicImage {
pub fn capture(&self, dimensions: LogicalSize) -> image::DynamicImage {
rgba_image_data_to_image(self.capture_rgba_image_data(dimensions))
}
/// Returns a RgbaImageData of the corresponding frame.
pub fn capture_rgba_image_data(&self, dimensions: (u32, u32)) -> RgbaImageData {
pub fn capture_rgba_image_data(&self, dimensions: LogicalSize) -> RgbaImageData {
let rect = Rect {
left: 0,
bottom: 0,
width: dimensions.0,
height: dimensions.1,
width: dimensions.width as u32,
height: dimensions.height as u32,
};
let blit_target = BlitTarget {
left: 0,
bottom: 0,
width: dimensions.0 as i32,
height: dimensions.1 as i32,
width: dimensions.width as i32,
height: dimensions.height as i32,
};
// Create temporary texture and blit the front buffer to it
let texture = SrgbTexture2d::empty(&self.display, dimensions.0, dimensions.1)
let texture = SrgbTexture2d::empty(
&self.display, dimensions.width as u32, dimensions.height as u32)
.unwrap();
let framebuffer = SimpleFrameBuffer::new(&self.display, &texture)
.unwrap();