proper 3d projection

This commit is contained in:
Chance 2025-03-22 18:19:01 -04:00
parent 9fec65ebc0
commit b270f3066f
Signed by: caznix
GPG key ID: 489D213143D753FD
14 changed files with 3761 additions and 209 deletions

View file

@ -1,30 +1,29 @@
use std::sync::Arc;
use std::sync::Arc;
use ctx::WgpuCtx;
use log::{debug, trace};
use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use log::{debug,trace};
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::event_loop::ControlFlow;
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::window::{Window, WindowId};
pub mod ctx;
#[derive(Default)]
pub struct App<'window> {
window: Option<Arc<Window>>,
ctx: Option<WgpuCtx<'window>>,
}
impl ApplicationHandler for App<'_> {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
if self.window.is_none() {
let win_attr = Window::default_attributes().with_title("Zenyx");
let window = Arc::new(event_loop
.create_window(win_attr)
.expect("create window err."));
let window = Arc::new(
event_loop
.create_window(win_attr)
.expect("create window err."),
);
self.window = Some(window.clone());
let wgpu_ctx = WgpuCtx::new_blocking(window.clone()).unwrap();
self.ctx = Some(wgpu_ctx)
@ -52,11 +51,12 @@ impl ApplicationHandler for App<'_> {
}
}
WindowEvent::Resized(size) => {
if let (Some(wgpu_ctx),Some(window)) = (&mut self.ctx, &self.window) {
if let (Some(wgpu_ctx), Some(window)) = (&mut self.ctx, &self.window) {
wgpu_ctx.resize(size.into());
window.request_redraw();
let size_str: String = size.height.to_string() + "x" + &size.width.to_string();
//self.window.as_ref().unwrap().set_title(&format!("you reszed the window to {size_str}"));
//self.window.as_ref().unwrap().set_title(&format!("you reszed the window to
// {size_str}"));
debug!("Window resized to {:?}", size_str);
}
}
@ -69,4 +69,4 @@ pub fn init_renderer(event_loop: EventLoop<()>) {
event_loop.set_control_flow(ControlFlow::Poll);
let mut app = App::default();
event_loop.run_app(&mut app).unwrap();
}
}