pub mod framebuf;
#[cfg(feature = "sdl")]
pub mod sdl;
use crate::types::{CoordTransform, Fixed, Rect};
pub struct DisplayInfo {
pub width: u16,
pub height: u16,
pub scale: Fixed,
pub format: crate::draw::texture::ColorFormat,
}
impl DisplayInfo {
pub fn transform(&self) -> CoordTransform {
CoordTransform::new(self.width, self.height, self.scale)
}
}
#[derive(Clone, Debug)]
pub enum InputEvent {
Touch { x: Fixed, y: Fixed },
TouchMove { x: Fixed, y: Fixed },
Release { x: Fixed, y: Fixed },
Key { code: u32, pressed: bool },
Quit,
}
pub trait Backend {
fn display_info(&self) -> DisplayInfo;
fn framebuffer(&mut self) -> &mut [u8];
fn flush(&mut self, area: &Rect);
fn poll_event(&mut self) -> Option<InputEvent>;
fn screen_rect(&self) -> Rect {
let info = self.display_info();
Rect::new(0, 0, info.width, info.height)
}
}