use crate::context::WgpuContext;
use crate::core::texture::DepthTexture;
use crate::window::event::Event;
#[derive(Debug, Clone, Copy)]
pub struct Viewport {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}
impl Viewport {
pub fn aspect(&self) -> f32 {
self.width as f32 / self.height as f32
}
}
pub struct FrameInput<'a> {
pub events: Vec<Event>,
pub elapsed_time: f64,
pub delta_time: f64,
pub viewport: Viewport,
pub ctx: &'a WgpuContext,
pub surface_view: &'a wgpu::TextureView,
pub depth_texture: &'a DepthTexture,
pub surface_format: wgpu::TextureFormat,
}
impl<'a> FrameInput<'a> {
pub fn width(&self) -> u32 {
self.viewport.width
}
pub fn height(&self) -> u32 {
self.viewport.height
}
pub fn aspect(&self) -> f32 {
self.viewport.aspect()
}
pub fn format(&self) -> wgpu::TextureFormat {
self.surface_format
}
}
#[derive(Debug, Clone, Default)]
pub struct FrameOutput {
pub exit: bool,
}
impl FrameOutput {
pub fn new() -> Self {
Self { exit: false }
}
pub fn exit() -> Self {
Self { exit: true }
}
}