Refactor logging system to switch between stdout and file logging

* Refactor logging to switch between stdout and file logging

* Use "clear" instead of "tput reset" for unix

* Remove redundant comments
This commit is contained in:
Jason Spalti 2024-12-02 11:51:39 -06:00 committed by BitSyndicate
parent b36fd151b5
commit cfe961ab71
Signed by: bitsyndicate
GPG key ID: 443E4198D6BBA6DE
16 changed files with 252 additions and 148 deletions
engine/src/core/renderer

View file

@ -1,12 +1,13 @@
use std::sync::Arc;
pub mod ctx;
use ctx::WgpuCtx;
use log2::{debug, error, trace};
use log::{debug, trace};
use std::sync::Arc;
use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use winit::event_loop::ActiveEventLoop;
use winit::window::{self, Window, WindowId};
pub mod ctx;
use winit::window::{Window, WindowId};
#[derive(Default)]
pub struct App<'window> {
window: Option<Arc<Window>>,
@ -17,9 +18,11 @@ 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)
@ -44,15 +47,15 @@ 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}"));
debug!("Window resized to {:?}", size_str);
let size_str: String = size.height.to_string() + "x" + &size.width.to_string();
debug!("Window resized to {:?}", size_str);
}
}
}
_ => trace!("Unhandled window event"),
}
}
}
}