macademia/
window.rs

1#[derive(Debug)]
2pub struct WindowProps<'a> {
3    pub title: &'a str,
4    pub width: usize,
5    pub height: usize,
6}
7
8impl<'a> WindowProps<'a> {
9    pub fn new(title: &'a str, width: usize, height: usize) -> WindowProps<'a> {
10        Self {
11            title,
12            width,
13            height
14        }
15    }
16}
17
18pub trait Window {
19    fn on_update(&mut self);
20    fn get_width(&self) -> usize;
21    fn get_height(&self) -> usize;
22    fn get_title(&self) -> &str;
23
24    fn set_vsync(&self, enabled: bool);
25    fn is_vsync(&self) -> bool;
26}
27
28#[cfg(target_os = "windows")]
29pub fn create<'a>(title: &'a str, width: usize, height: usize) -> Box<dyn Window + 'a> {
30    use crate::platform::windows::window::WindowsWindow;
31
32    Box::new(WindowsWindow::new(title, width, height))
33}
34
35#[cfg(target_os = "linux")]
36pub fn create<'a>(title: &'a str, width: usize, height: usize) -> Box<dyn Window + 'a> {
37    use crate::{platform::linux::window::LinuxWindow};
38
39    Box::new(LinuxWindow::new(title, width, height))
40}
41