27 lines
829 B
Rust
27 lines
829 B
Rust
|
use ash::prelude::VkResult;
|
||
|
use ash::vk;
|
||
|
use crate::hello_triangle::swapchain::VulkanSwapchain;
|
||
|
|
||
|
pub struct VulkanFramebuffer {
|
||
|
pub framebuffer: vk::Framebuffer,
|
||
|
}
|
||
|
|
||
|
impl VulkanFramebuffer {
|
||
|
pub fn new(device: &ash::Device, image_view: &vk::ImageView, render_pass: &vk::RenderPass, width: u32, height: u32) -> VkResult<VulkanFramebuffer> {
|
||
|
let attachments = &[*image_view];
|
||
|
let framebuffer_info = vk::FramebufferCreateInfo::builder()
|
||
|
.render_pass(*render_pass)
|
||
|
.attachments(attachments)
|
||
|
.width(width)
|
||
|
.height(height)
|
||
|
.layers(1)
|
||
|
.build();
|
||
|
|
||
|
unsafe {
|
||
|
let framebuffer = device.create_framebuffer(&framebuffer_info, None)?;
|
||
|
Ok(VulkanFramebuffer {
|
||
|
framebuffer
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|