use std::sync::{Arc, Mutex}; use vulkan_rs::prelude::*; #[cfg(feature = "audio")] use audio::*; pub trait ContextInterface: Send + Sync { fn device(&self) -> &Arc; fn queue(&self) -> &Arc>; fn format(&self) -> VkFormat; fn image_layout(&self) -> VkImageLayout; fn image_count(&self) -> usize; fn images(&self) -> TargetMode>>; fn width(&self) -> u32; fn height(&self) -> u32; #[cfg(feature = "audio")] fn sound_handler(&self) -> std::sync::MutexGuard<'_, SoundHandler>; } pub enum TargetMode { Mono(T), Stereo(T, T), } impl TargetMode { pub fn mono(&self) -> &T { match self { TargetMode::Mono(s) => s, TargetMode::Stereo(_, _) => panic!("Expected another target mode"), } } pub fn mono_mut(&mut self) -> &mut T { match self { TargetMode::Mono(s) => s, TargetMode::Stereo(_, _) => panic!("Expected another target mode"), } } pub fn stereo(&self) -> (&T, &T) { match self { TargetMode::Mono(_) => panic!("Expected another target mode"), TargetMode::Stereo(l, r) => (l, r), } } pub fn stereo_mut(&mut self) -> (&mut T, &mut T) { match self { TargetMode::Mono(_) => panic!("Expected another target mode"), TargetMode::Stereo(l, r) => (l, r), } } } impl Clone for TargetMode { fn clone(&self) -> TargetMode { match self { TargetMode::Mono(t) => TargetMode::Mono(t.clone()), TargetMode::Stereo(lhs, rhs) => TargetMode::Stereo(lhs.clone(), rhs.clone()), } } }