Simplify function parameter

This commit is contained in:
Hanno Braun 2025-03-25 21:06:00 +01:00
parent 770724ac44
commit 6fc4675011
2 changed files with 8 additions and 9 deletions

View File

@ -1,13 +1,10 @@
use std::{io, mem::size_of, vec}; use std::{io, mem::size_of, sync::Arc, vec};
use thiserror::Error; use thiserror::Error;
use tracing::{error, trace}; use tracing::{error, trace};
use wgpu::util::DeviceExt as _; use wgpu::util::DeviceExt as _;
use crate::{ use crate::{camera::Camera, window::WindowSize};
camera::Camera,
window::{Window, WindowSize},
};
use super::{ use super::{
DEPTH_FORMAT, DeviceError, SAMPLE_COUNT, device::Device, DEPTH_FORMAT, DeviceError, SAMPLE_COUNT, device::Device,
@ -37,14 +34,16 @@ pub struct Renderer {
impl Renderer { impl Renderer {
/// Returns a new `Renderer`. /// Returns a new `Renderer`.
pub async fn new(window: &Window) -> Result<Self, RendererInitError> { pub async fn new(
let window_size = window.inner.inner_size(); window: Arc<winit::window::Window>,
) -> Result<Self, RendererInitError> {
let window_size = window.inner_size();
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(), backends: wgpu::Backends::all(),
..Default::default() ..Default::default()
}); });
let surface = instance.create_surface(window.inner.clone())?; let surface = instance.create_surface(window)?;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
for adapter in instance.enumerate_adapters(wgpu::Backends::all()) { for adapter in instance.enumerate_adapters(wgpu::Backends::all()) {

View File

@ -44,7 +44,7 @@ impl ViewerWindow {
)?, )?,
), ),
}; };
let renderer = Renderer::new(&window).await?; let renderer = Renderer::new(window.inner.clone()).await?;
Ok(Self { Ok(Self {
new_screen_size: None, new_screen_size: None,