rFactor2_vk_hud/src/overlay/rendering.rs

47 lines
1.2 KiB
Rust
Raw Normal View History

2023-01-12 09:10:09 +00:00
use anyhow::Result;
use vulkan_rs::prelude::*;
2023-01-12 12:52:44 +00:00
use std::sync::{Arc, Mutex};
use super::pipeline::SingleColorPipeline;
2023-01-12 09:10:09 +00:00
pub struct Rendering {
swapchain: Arc<Swapchain>,
2023-01-12 12:52:44 +00:00
pipeline: SingleColorPipeline,
render_target: RenderTarget,
images: Vec<Arc<Image>>,
2023-01-12 09:10:09 +00:00
}
impl Rendering {
2023-01-12 12:52:44 +00:00
pub fn new(
device: Arc<Device>,
queue: Arc<Mutex<Queue>>,
swapchain: Arc<Swapchain>,
) -> Result<Self> {
let images = swapchain.wrap_images(&swapchain.vk_images()?, &queue)?;
let render_target = RenderTarget::builder()
.add_sub_pass(
SubPass::builder(swapchain.width(), swapchain.height())
.set_prepared_targets(&images, 0, [0.0, 0.0, 0.0, 1.0], false)
.build(&device, &queue)?,
)
.build(&device)?;
Ok(Self {
swapchain,
pipeline: SingleColorPipeline::new(device, render_target.render_pass())?,
render_target,
images,
})
}
pub fn swapchain(&self) -> &Arc<Swapchain> {
&self.swapchain
2023-01-12 09:10:09 +00:00
}
pub fn render(&mut self) -> Result<VkSubmitInfo> {
todo!()
}
}