engine/presentation/src/traits.rs

66 lines
1.7 KiB
Rust
Raw Normal View History

2024-08-23 11:22:09 +00:00
use ui::prelude::*;
use vulkan_rs::prelude::*;
use crate::Result;
use std::sync::Arc;
use crate::prelude::*;
pub trait TScene: Send + Sync {
fn process(
&mut self,
buffer_recorder: &mut CommandBufferRecorder<'_>,
images: &TargetMode<Vec<Arc<Image>>>,
indices: &TargetMode<usize>,
) -> Result<()>;
fn resize(
&mut self,
window_width: f32,
window_height: f32,
images: &TargetMode<Vec<Arc<Image>>>,
) -> Result<()>;
}
pub trait PostProcess: Send + Sync {
/// higher priority means, it is executed earlier
fn priority(&self) -> u32;
fn process(
&self,
buffer_recorder: &mut CommandBufferRecorder<'_>,
indices: &TargetMode<usize>,
) -> Result<()>;
fn resize(&self, width: u32, height: u32) -> Result<()>;
}
pub trait RenderCore: std::fmt::Debug + Send + Sync {
fn next_frame(&mut self) -> Result<bool>;
fn resize(&mut self, w: u32, h: u32) -> Result<()>;
fn format(&self) -> VkFormat;
fn image_layout(&self) -> VkImageLayout {
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
}
fn set_clear_color(&self, color: [f32; 4]);
// scene handling
fn scene(&self) -> &Box<dyn TScene>;
fn scene_mut(&mut self) -> &mut Box<dyn TScene>;
// post process handling
fn add_post_processing_routine(&self, post_process: Arc<dyn PostProcess>);
fn remove_post_processing_routine(&self, post_process: Arc<dyn PostProcess>);
fn clear_post_processing_routines(&self);
// getter
fn image_count(&self) -> usize;
fn images(&self) -> TargetMode<Vec<Arc<Image>>>;
fn width(&self) -> u32;
fn height(&self) -> u32;
fn transformations(&self) -> Option<(VRTransformations, VRTransformations)>;
}