engine/presentation/src/traits.rs

51 lines
1.3 KiB
Rust
Raw Normal View History

use ecs::World;
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::*;
2025-02-28 15:41:59 +00:00
pub trait TScene: Send + Sync + 'static {
2024-08-23 11:22:09 +00:00
fn process(
&mut self,
buffer_recorder: &mut CommandBufferRecorder<'_>,
images: &TargetMode<Vec<Arc<Image>>>,
indices: &TargetMode<usize>,
2025-02-27 13:14:29 +00:00
world: &World,
2024-08-23 11:22:09 +00:00
) -> Result<()>;
fn resize(
&mut self,
window_width: f32,
window_height: f32,
images: &TargetMode<Vec<Arc<Image>>>,
) -> Result<()>;
}
pub trait RenderCore: std::fmt::Debug + Send + Sync {
fn next_frame(&mut self, world: &mut World) -> Result<bool>;
2024-08-23 11:22:09 +00:00
fn resize(&mut self, world: &mut World, w: u32, h: u32) -> Result<()>;
2024-08-23 11:22:09 +00:00
fn format(&self) -> VkFormat;
fn image_layout(&self) -> VkImageLayout {
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
}
2025-02-28 15:41:59 +00:00
// render routines
fn add_render_routine<T: TScene>(&mut self, priority: u32);
fn remove_render_routine<T: TScene>(&mut self);
2024-08-23 11:22:09 +00:00
2025-02-28 15:41:59 +00:00
fn set_clear_color(&self, color: [f32; 4]);
2024-08-23 11:22:09 +00:00
// 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)>;
}