summaryrefslogtreecommitdiffstats
path: root/wgpu/src/viewport.rs
blob: a4bcb704c70d70e0bdb0fef7bfa2cab08d530562 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
    }
}