diff --git a/src/main.cpp b/src/main.cpp index 3d12239..d395d07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,6 +66,8 @@ class VulkanApp { vk::UniquePipelineLayout mPipelineLayout; vk::UniquePipeline mGraphicsPipeline; + std::vector mSwapChainFramebuffers; + struct QueueFamilyIndices { std::optional graphics_family; std::optional present_family; @@ -117,6 +119,7 @@ class VulkanApp { createImageViews(); createRenderPass(); createGraphicsPipeline(); + createFramebuffers(); } fn mainLoop() -> void { @@ -444,6 +447,23 @@ class VulkanApp { mGraphicsPipeline = mDevice->createGraphicsPipelineUnique(nullptr, pipelineInfo).value; } + fn createFramebuffers() -> void { + mSwapChainFramebuffers.resize(mSwapChainImageViews.size()); + + for (usize i = 0; i < mSwapChainImageViews.size(); i++) { + vk::FramebufferCreateInfo framebufferInfo { + .renderPass = mRenderPass.get(), + .attachmentCount = 1, + .pAttachments = &mSwapChainImageViews[i].get(), + .width = mSwapChainExtent.width, + .height = mSwapChainExtent.height, + .layers = 1, + }; + + mSwapChainFramebuffers[i] = mDevice->createFramebufferUnique(framebufferInfo); + } + } + fn createShaderModule(const std::vector& code) -> vk::UniqueShaderModule { vk::ShaderModuleCreateInfo createInfo { .codeSize = code.size(), .pCode = std::bit_cast(code.data()) };