mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-25 13:18:21 -06:00
use Arc<Window>
instead of create_surface_unsafe
This commit is contained in:
parent
840529511c
commit
a7b403b0a5
|
@ -1,6 +1,6 @@
|
||||||
|
use std::sync::Arc;
|
||||||
use pollster::FutureExt;
|
use pollster::FutureExt;
|
||||||
use shipyard::Unique;
|
use shipyard::Unique;
|
||||||
use winapi::shared::cfg;
|
|
||||||
use winit::{
|
use winit::{
|
||||||
event_loop::ActiveEventLoop,
|
event_loop::ActiveEventLoop,
|
||||||
window::{Fullscreen, Window},
|
window::{Fullscreen, Window},
|
||||||
|
@ -10,6 +10,7 @@ use crate::settings::{GameSettings, FullscreenMode};
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
pub struct Renderer {
|
pub struct Renderer {
|
||||||
|
window: Arc<Window>,
|
||||||
instance: wgpu::Instance,
|
instance: wgpu::Instance,
|
||||||
surface: wgpu::Surface<'static>,
|
surface: wgpu::Surface<'static>,
|
||||||
device: wgpu::Device,
|
device: wgpu::Device,
|
||||||
|
@ -17,9 +18,6 @@ pub struct Renderer {
|
||||||
surface_config: wgpu::SurfaceConfiguration,
|
surface_config: wgpu::SurfaceConfiguration,
|
||||||
size: PhysicalSize<u32>,
|
size: PhysicalSize<u32>,
|
||||||
// pub depth_texture: wgpu::Texture,
|
// pub depth_texture: wgpu::Texture,
|
||||||
|
|
||||||
//must be last due to drop order
|
|
||||||
window: Window,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderer {
|
impl Renderer {
|
||||||
|
@ -72,7 +70,7 @@ impl Renderer {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let window = event_loop.create_window(window_attributes).unwrap();
|
let window = Arc::new(event_loop.create_window(window_attributes).unwrap());
|
||||||
|
|
||||||
let size = window.inner_size();
|
let size = window.inner_size();
|
||||||
|
|
||||||
|
@ -91,10 +89,11 @@ impl Renderer {
|
||||||
|
|
||||||
// Create a surface with `create_surface_unsafe` to get a surface with 'static lifetime
|
// Create a surface with `create_surface_unsafe` to get a surface with 'static lifetime
|
||||||
// It should never outlive the window it's created from
|
// It should never outlive the window it's created from
|
||||||
let surface = unsafe {
|
// let surface = unsafe {
|
||||||
let target = wgpu::SurfaceTargetUnsafe::from_window(&window).unwrap();
|
// let target = wgpu::SurfaceTargetUnsafe::from_window(&window).unwrap();
|
||||||
instance.create_surface_unsafe(target).unwrap()
|
// instance.create_surface_unsafe(target).unwrap()
|
||||||
};
|
// };
|
||||||
|
let surface = instance.create_surface(Arc::clone(&window)).unwrap();
|
||||||
|
|
||||||
let adapter = instance.request_adapter(
|
let adapter = instance.request_adapter(
|
||||||
&wgpu::RequestAdapterOptions {
|
&wgpu::RequestAdapterOptions {
|
||||||
|
|
Loading…
Reference in a new issue