rFactor2_vk_hud/src/overlay/mod.rs

51 lines
1.1 KiB
Rust
Raw Normal View History

2023-01-12 09:10:09 +00:00
use self::rendering::Rendering;
mod rendering;
use anyhow::Result;
use std::sync::Arc;
use vulkan_rs::prelude::*;
#[derive(Default)]
pub struct Overlay {
instance: Option<Arc<Instance>>,
device: Option<Arc<Device>>,
rendering: Option<Rendering>,
}
impl Overlay {
pub const fn new() -> Self {
Self {
instance: None,
device: None,
rendering: None,
}
}
pub fn set_instance(&mut self, instance: Arc<Instance>) {
self.instance = Some(instance);
}
pub fn instance(&self) -> Arc<Instance> {
self.instance.as_ref().unwrap().clone()
}
pub fn set_device(&mut self, device: Arc<Device>) {
self.device = Some(device);
}
pub fn device(&self) -> Arc<Device> {
self.device.as_ref().unwrap().clone()
}
pub fn create_rendering(&mut self, swapchain: Arc<Swapchain>) -> Result<()> {
self.rendering = Some(Rendering::new(swapchain));
Ok(())
}
pub fn render(&mut self) -> Result<VkSubmitInfo> {
self.rendering.as_mut().unwrap().render()
}
}