pub struct AppInfo {
pub(crate) window_pixels: (u32, u32),
pub(crate) min_dims: (f64, f64),
pub(crate) max_dims: (f64, f64),
pub(crate) tile_width: Option<u32>,
pub(crate) title: &'static str,
pub(crate) target_fps: f64,
pub(crate) print_workload_info: bool,
pub(crate) print_gl_info: bool,
}
impl AppInfo {
pub fn with_max_dims(max_width: f64, max_height: f64) -> AppInfo {
assert!(max_width >= 1. && max_width <= 3000., "unrealistic max_width: {}", max_width);
assert!(max_height >= 1. && max_height <= 3000., "unrealistic max_height: {}", max_height);
AppInfo {
window_pixels: (800, 600),
min_dims: (0., 0.),
max_dims: (max_width, max_height),
tile_width: None,
title: "untitled app",
target_fps: 60.,
print_workload_info: false,
print_gl_info: false,
}
}
pub fn min_dims(mut self, min_width: f64, min_height: f64) -> Self {
assert!(self.min_dims.0 <= self.max_dims.0 && self.min_dims.1 <= self.max_dims.1);
self.min_dims = (min_width, min_height);
self
}
pub fn tile_width(mut self, tile_width: u32) -> Self {
assert!(tile_width > 0 && tile_width <= 10000, "unrealistic tile_width {}", tile_width);
self.tile_width = Some(tile_width);
self
}
pub fn title(mut self, title: &'static str) -> Self { self.title = title; self }
pub fn native_dims(mut self, width: u32, height: u32) -> Self {
assert!(width >= 10 && width <= 3000, "unrealistic window width {}", width);
assert!(height >= 10 && height <= 3000, "unrealistic window height {}", height);
self.window_pixels = (width, height);
self
}
pub fn target_fps(mut self, target_fps: f64) -> Self {
assert!(target_fps >= 20. && target_fps < 200., "unrealistic target_fps: {}", target_fps);
self.target_fps = target_fps;
self
}
pub fn print_workload_info(mut self) -> Self { self.print_workload_info = true; self }
pub fn print_gl_info(mut self) -> Self { self.print_gl_info = true; self }
}