Give render context ownership of window
This commit is contained in:
parent
1a92b52630
commit
0dd7bbd37e
|
@ -1,6 +1,7 @@
|
|||
use winit::{dpi::PhysicalSize, window::Window};
|
||||
|
||||
pub struct Context {
|
||||
pub window: Window,
|
||||
pub instance: wgpu::Instance,
|
||||
pub size: PhysicalSize<u32>,
|
||||
pub surface: wgpu::Surface,
|
||||
|
@ -11,7 +12,7 @@ pub struct Context {
|
|||
}
|
||||
|
||||
impl Context {
|
||||
pub async fn new(window: &Window, limits: wgpu::Limits) -> Self {
|
||||
pub async fn new(window: Window, limits: wgpu::Limits) -> Self {
|
||||
log::info!("Initialising WGPU context...");
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::Backends::VULKAN,
|
||||
|
@ -57,6 +58,7 @@ impl Context {
|
|||
surface.configure(&device, &surface_config);
|
||||
|
||||
Self {
|
||||
window,
|
||||
instance,
|
||||
size,
|
||||
surface,
|
||||
|
|
|
@ -15,13 +15,13 @@ pub async fn run() {
|
|||
.build(&event_loop)
|
||||
.unwrap();
|
||||
|
||||
let mut render_ctx = gfx::Context::new(&window, wgpu::Limits::default()).await;
|
||||
let mut render_ctx = gfx::Context::new(window, wgpu::Limits::default()).await;
|
||||
|
||||
event_loop.run(move |event, _, control_flow| match event {
|
||||
Event::WindowEvent {
|
||||
ref event,
|
||||
window_id,
|
||||
} if window_id == window.id() => match event {
|
||||
} if window_id == render_ctx.window.id() => match event {
|
||||
WindowEvent::CloseRequested
|
||||
| WindowEvent::KeyboardInput {
|
||||
input:
|
||||
|
|
Loading…
Reference in New Issue