diff options
author | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 00:55:23 +1100 |
---|---|---|
committer | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 00:55:23 +1100 |
commit | fa3f688360218b3f8a049797342e8026064fd4c1 (patch) | |
tree | d50cf9feae53153e6cafef6e69b8cf10bb515fd3 /src | |
parent | eda3e214131903e03a9ebf69e9746c2d2d609be0 (diff) |
src/main.cpp: Implement Framebuffers
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 001b4e5..31a0c14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,6 +45,7 @@ private: VkExtent2D swapChainExtent; std::vector<VDeleter<VkImageView>> swapChainImageViews; + std::vector<VDeleter<VkFramebuffer>> swapChainFramebuffers; struct QueueFamilyIndices { int graphicsFamily = -1; @@ -92,6 +93,29 @@ private: createImageViews(); createRenderPass(); createGraphicsPipeline(); + createFramebuffers(); + } + + void createFramebuffers() { + swapChainFramebuffers.resize(swapChainImageViews.size(), VDeleter<VkFramebuffer>{device, vkDestroyFramebuffer}); + + for (size_t i = 0; i < swapChainImageViews.size(); i++) { + VkImageView attachments[] = { + swapChainImageViews[i] + }; + + VkFramebufferCreateInfo framebufferInfo = {}; + framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; + framebufferInfo.renderPass = renderPass; + framebufferInfo.attachmentCount = 1; + framebufferInfo.pAttachments = attachments; + framebufferInfo.width = swapChainExtent.width; + framebufferInfo.height = swapChainExtent.height; + framebufferInfo.layers = 1; + + if (vkCreateFramebuffer(device, &framebufferInfo, nullptr, swapChainFramebuffers[i].replace()) != VK_SUCCESS) + throw std::runtime_error("failed to create framebuffer!"); + } } void createRenderPass() { |