Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s
Refactor Vulkan initialization to merge logical and physical device management into a unified `VkDevice` struct. Improved logging for Vulkan instance creation and surface management. Added methods to `VkPhysicalDevice` and `VkSurface` for more detailed querying of physical device capabilities.
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use winit::application::ApplicationHandler;
|
|
use winit::event::WindowEvent;
|
|
use winit::event_loop::ActiveEventLoop;
|
|
use winit::window::{WindowId};
|
|
use crate::display::window::Window;
|
|
use crate::vulkan::VkRenderContext;
|
|
|
|
pub struct App {
|
|
window: Window,
|
|
render_context: Option<VkRenderContext>,
|
|
}
|
|
|
|
impl App {
|
|
pub fn new(window: Window) -> Self {
|
|
Self {
|
|
window,
|
|
render_context: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ApplicationHandler for App {
|
|
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
|
self.window.create_window(event_loop)
|
|
.map_err(|err| format!("Failed to create window: {}", err))
|
|
.unwrap();
|
|
|
|
self.render_context = VkRenderContext::init(&self.window).ok();
|
|
}
|
|
|
|
fn window_event(&mut self, event_loop: &ActiveEventLoop, id: WindowId, event: WindowEvent) {
|
|
match event {
|
|
WindowEvent::CloseRequested => {
|
|
log::debug!("The close button was pressed; stopping");
|
|
event_loop.exit();
|
|
}
|
|
_ => self.window.window_event(event_loop, id, event),
|
|
}
|
|
}
|
|
}
|