Allow iced_wgpu to render to any TextureView

This commit is contained in:
Héctor Ramón Jiménez 2020-02-09 03:25:13 +01:00
parent 95880ca74b
commit f1e20a61f1
13 changed files with 355 additions and 240 deletions

32
wgpu/src/viewport.rs Normal file
View file

@ -0,0 +1,32 @@
use crate::Transformation;
#[derive(Debug)]
pub struct Viewport {
width: u32,
height: u32,
scale_factor: f32,
transformation: Transformation,
}
impl Viewport {
pub fn new(width: u32, height: u32, scale_factor: f64) -> Viewport {
Viewport {
width,
height,
scale_factor: scale_factor as f32,
transformation: Transformation::orthographic(width, height),
}
}
pub fn dimensions(&self) -> (u32, u32) {
(self.width, self.height)
}
pub fn scale_factor(&self) -> f32 {
self.scale_factor
}
pub(crate) fn transformation(&self) -> Transformation {
self.transformation
}
}