Basic output system

This commit is contained in:
pyrex committed 2024-04-22 19:57:27 -07:00
1 parent 082fbf3e80
commit aae336ca66
13 files changed
+959 -91

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
use minifb::{Window, WindowOptions};
use viperid::{Device, VResult, SCREEN_H, SCREEN_W};
pub fn host(
device: Device,
mut update: impl FnMut() -> VResult<()>
) -> VResult<()> {
let mut window = Window::new(
"viperid",
SCREEN_W,
SCREEN_H,
WindowOptions::default()
)?;
// limit to 60FPS
window.limit_update_rate(Some(std::time::Duration::from_micros(16600)));
let mut buffer: Vec<u32> = vec![0; SCREEN_W * SCREEN_H];
while window.is_open() {
update()?;
device.shared.screen.to_bitmap(&mut buffer);
window.update_with_buffer(&buffer, SCREEN_W, SCREEN_H)?;
}
Ok(())
}