this may actually work

This commit is contained in:
2025-07-01 02:43:35 +02:00
parent b2a874da29
commit 9a626fb1bc
5 changed files with 250 additions and 1785 deletions
Generated
+221 -1724
View File
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -7,6 +7,5 @@ edition = "2021"
name = "osgui" name = "osgui"
[dependencies] [dependencies]
pollster = "0.4.0" minifb = "0.28.0"
wgpu = "24.0.5"
winit = "0.30.11"
-44
View File
@@ -1,44 +0,0 @@
use winit::application::ApplicationHandler;
use winit::dpi::LogicalSize;
use winit::event::WindowEvent;
use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop};
use winit::window::{Window, WindowAttributes, WindowId};
struct App {
window: Option<Window>,
attr: WindowAttributes,
}
impl App {
pub fn new(attr: WindowAttributes) -> App {
App { window: None, attr }
}
}
impl ApplicationHandler for App {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
self.window = Some(event_loop.create_window(self.attr.clone()).unwrap());
}
fn window_event(&mut self, event_loop: &ActiveEventLoop, _id: WindowId, event: WindowEvent) {
match event {
WindowEvent::CloseRequested => {
event_loop.exit();
}
WindowEvent::RedrawRequested => {
self.window.as_ref().unwrap().request_redraw();
}
_ => (),
}
}
}
pub fn run(width: f64, height: f64) {
let event_loop = EventLoop::new().unwrap();
event_loop.set_control_flow(ControlFlow::Poll);
event_loop.set_control_flow(ControlFlow::Wait);
let mut w = WindowAttributes::default();
w.inner_size = Some(winit::dpi::Size::Logical(LogicalSize::new(width, height)));
let mut app = App::new(w);
event_loop.run_app(&mut app).unwrap();
}
+21 -11
View File
@@ -1,19 +1,29 @@
mod app; use minifb::Window;
pub struct Window { pub struct App {
width: f64, window: Window,
height: f64,
} }
impl Window { impl App {
pub fn new() -> Window { pub fn new(win: Window) -> Self {
Window { Self { window: win }
width: 1000.0, }
height: 650.0,
pub fn run(&mut self) {
while self.window.is_open() {
self.render();
} }
} }
pub fn run(&self) { fn render(&mut self) {
app::run(self.width, self.height); let (w, h) = self.window.get_size();
let mut buffer = vec![0; w * h];
for y in 100..200 {
for x in 150..300 {
buffer[y * h + x] = 0xFF00FF;
}
}
self.window.update_with_buffer(&buffer, w, h).unwrap();
} }
} }
+6 -3
View File
@@ -1,7 +1,10 @@
use osgui::Window; use minifb::{Window, WindowOptions};
use osgui::App;
fn main() { fn main() {
let win = Window::new(); let window = Window::new("minifb example", 500, 500, WindowOptions::default()).unwrap();
win.run(); let mut app = App::new(window);
app.run();
} }