diff --git a/gb-emu/src/renderer/pixels.rs b/gb-emu/src/renderer/pixels.rs index d7ede50..73cac56 100644 --- a/gb-emu/src/renderer/pixels.rs +++ b/gb-emu/src/renderer/pixels.rs @@ -1,7 +1,9 @@ use std::sync::Arc; -use pixels::{Pixels, SurfaceTexture}; -use winit::window::Window; +use pixels::{ + raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}, + Pixels, SurfaceTexture, +}; use super::ResolutionData; @@ -20,9 +22,9 @@ pub struct RendererBackend { } impl RendererBackend { - pub fn new( + pub fn new( resolutions: ResolutionData, - window: &Window, + window: &W, _: WindowOptions, _: Arc, ) -> Self { @@ -31,7 +33,11 @@ impl RendererBackend { } } - pub fn resize(&mut self, resolutions: ResolutionData, window: &Window) { + pub fn resize( + &mut self, + resolutions: ResolutionData, + window: &W, + ) { self.pixels = new_pixels(resolutions, window); } @@ -46,8 +52,11 @@ impl RendererBackend { } } -fn new_pixels(resolutions: ResolutionData, window: &Window) -> Pixels { - let surface_texture: SurfaceTexture<'_, Window> = +fn new_pixels( + resolutions: ResolutionData, + window: &W, +) -> Pixels { + let surface_texture: SurfaceTexture<'_, W> = SurfaceTexture::new(resolutions.real_width, resolutions.real_height, window); pixels::PixelsBuilder::new( resolutions.scaled_width, diff --git a/gb-emu/src/renderer/vulkan/types.rs b/gb-emu/src/renderer/vulkan/types.rs index 6b98abd..08a8164 100644 --- a/gb-emu/src/renderer/vulkan/types.rs +++ b/gb-emu/src/renderer/vulkan/types.rs @@ -3,7 +3,6 @@ use ash::{ vk, Device, }; use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; -use winit::window::Window; use crate::window::ResolutionData; @@ -217,7 +216,10 @@ pub(super) struct SurfaceData { } impl SurfaceData { - pub(super) unsafe fn new(window: &Window, manager: &RendererBackendManager) -> Self { + pub(super) unsafe fn new( + window: &W, + manager: &RendererBackendManager, + ) -> Self { let surface = ash_window::create_surface( &manager.entry, &manager.instance, diff --git a/gb-emu/src/renderer/vulkan/vulkan.rs b/gb-emu/src/renderer/vulkan/vulkan.rs index 4d6062a..4ad3eff 100644 --- a/gb-emu/src/renderer/vulkan/vulkan.rs +++ b/gb-emu/src/renderer/vulkan/vulkan.rs @@ -3,8 +3,7 @@ use std::{mem, path::PathBuf, sync::Arc}; use ash::{util::Align, vk, Entry, Instance}; use ash_window::enumerate_required_extensions; use librashader::runtime::vk::{FilterChain, FilterChainOptions, FrameOptions, VulkanObjects}; -use raw_window_handle::RawDisplayHandle; -use winit::window::Window; +use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle}; use self::{ types::{FramebufferData, SurfaceData, SwapchainData, Vertex, VulkanData, SHADER_INPUT_FORMAT}, @@ -88,9 +87,9 @@ pub struct WindowOptions { } impl RendererBackend { - pub fn new( + pub fn new( resolutions: ResolutionData, - window: &Window, + window: &W, options: WindowOptions, manager: Arc, ) -> Self { @@ -121,7 +120,11 @@ impl RendererBackend { } } - pub fn resize(&mut self, resolutions: ResolutionData, _window: &Window) { + pub fn resize( + &mut self, + resolutions: ResolutionData, + _window: &W, + ) { unsafe { self.inner.resize(resolutions, self.manager.as_ref()) }; } @@ -152,9 +155,9 @@ struct VulkanWindowInner { } impl VulkanWindowInner { - unsafe fn new( + unsafe fn new( resolutions: ResolutionData, - window: &Window, + window: &W, manager: &RendererBackendManager, ) -> Self { let surface = SurfaceData::new(window, manager); diff --git a/gb-vst/src/ui.rs b/gb-vst/src/ui.rs index f0503c0..fbb10ed 100644 --- a/gb-vst/src/ui.rs +++ b/gb-vst/src/ui.rs @@ -12,7 +12,11 @@ use gb_emu_lib::{ }; use keyboard_types::{Code, KeyState}; use nih_plug::prelude::*; -use pixels::{wgpu::PowerPreference, Pixels, SurfaceTexture}; +use pixels::{ + raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}, + wgpu::PowerPreference, + Pixels, SurfaceTexture, +}; use crate::{Frame, FrameReceiver, JoypadInfo, JoypadSender}; @@ -100,6 +104,8 @@ impl EmulatorWindow { frame_receiver: Arc, joypad_sender: Arc, ) -> Self { + window.raw_window_handle(); + window.raw_display_handle(); let info = WindowInfo::from_logical_size( Size::new(WIDTH as f64, HEIGHT as f64), EXTRA_SCALE as f64,